Updating a version through rest API returns invalid JSON
|Assignee:||Jean-Philippe Lang||% Done:|
After PUTing a successful version update API request to
/versions/1234.json, a response body consisting of one space is returned, while it declares itself to be 'Content-Type: application/json'.
One space (" ") is not valid JSON, so a client interpreting the response according to the content-type header will issue an error.
(reported before in #9598, but does not mention content-type clash)
#5 Updated by Etienne Massip almost 7 years ago
After discussion, it was eventually overrided by a new commit setting the response code to
204 and setting the body back to an single space.
I would do the way Rails do.
Edit: not an empty string, a single space.
#8 Updated by Jean-Philippe Lang almost 7 years ago
I have made a few tests with JQuery. It gives an error when responding with a one space response body indeed. But it seems to work fine with a 200 response and an empty body, even if the response Content-Type is set to text/json. It gives no error and returns null.
So I propose to just change the "one space" response body to an empty body.
#12 Updated by Etienne Massip almost 7 years ago
FTR, there exists a jQuery bug which has been closed.
Quote : An example of this is the 204 No Content status. The HTTP specification is unclear as to the inclusion of content-type. It does not forbid including it at any rate. But it does forbid the inclusion of a message-body.