UpCloudLtd / upcloud-python-api

Python client for UpCloud's API
MIT License
53 stars 21 forks source link

Api returns 400 Bad Request when specifying the charset #60

Closed LunicLynx closed 5 years ago

LunicLynx commented 5 years ago

Working:

POST https://api.upcloud.com/1.2/server/<server-id>/stop
Authorization: Basic {{username}} {{password}}
Content-Type: application/json

{"stop_server":{"stop_type":"soft","timeout":"60"}}

Not working:

Request

POST https://api.upcloud.com/1.2/server/<server-id>/stop
Authorization: Basic {{username}} {{password}}
Content-Type: application/json; charset=utf-8

{"stop_server":{"stop_type":"soft","timeout":"60"}}

Response

HTTP/1.1 400 Bad Request
Date: Fri, 02 Aug 2019 10:12:28 GMT
Server: Apache
Content-Length: 141
Connection: close
Content-Type: application/json; charset=UTF-8

{ "error": { "error_code": "CONTENT_TYPE_INVALID", "error_message": "The Content-Type header has an invalid value." }}

In my opinion, setting the charset shoud not result in an error here.

scop commented 5 years ago

Agreed, and fixed now, thanks for the report! Only UTF-8 is still supported, though. The fix is on the service side, no need for client changes.