Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

POST Inconsistency #84

Open
jaydson opened this issue May 21, 2015 · 2 comments
Open

POST Inconsistency #84

jaydson opened this issue May 21, 2015 · 2 comments

Comments

@jaydson
Copy link

jaydson commented May 21, 2015

The JSONAPI spec says:

Any requests that contain content MUST include a Content-Type header whose value is application/vnd.api+json

Harvester is failing when the supposed header is sent:

curl -XPOST -H "Content-type: application/vnd.api+json" -d '{
  "artists": [ { "name": "Sepultura" }]
}' 'http://localhost:1337/artists'

The result:

{
  "errors": [
    {
      "status": 500,
      "detail": "TypeError: Cannot read property 'forEach' of undefined",
      "href": "about:blank",
      "title": "Oops, something went wrong."
    }
  ]
}

Changing the Content-type to application/json works just fine.
The inconsistency here is Harvester (or Fortune) are not following the spec IMHO.

@dclucas
Copy link

dclucas commented May 21, 2015

Sounds about right. And the error message could be better. Will check on the content type first, since throwing on the wrong content-type could break some extension cases...

@jaydson
Copy link
Author

jaydson commented May 21, 2015

Yep.
Funny thing is when you try to set a random header, the message is pretty clear, and more than that, says that i must to use application/vnd.api+json or application/json:

curl -XPOST -H "Content-type: application/xxx" -d '{
  "artists": [ { "name": "Sepultura" }]
}' 'http://localhost:1337/artists'

Result:

{
  "errors": [
    {
      "status": 412,
      "href": "about:blank",
      "title": "Request header \"Content-Type\" must be one of: application/vnd.api+json, application/json",
      "detail": ""
    }
  ]
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants