Skip to content

Get requests REQUIRE application/vnd.api+json request header #774

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wayne-o opened this issue May 26, 2020 · 7 comments
Closed

Get requests REQUIRE application/vnd.api+json request header #774

wayne-o opened this issue May 26, 2020 · 7 comments

Comments

@wayne-o
Copy link
Contributor

wayne-o commented May 26, 2020

Description

According to this: #596 (comment)

GET requests should not require application/vnd.api+json header

Making a request to the reports example using a browser - so no application/vnd.api+json header - returns the following error:

errors: [
{
id: "7620a90e-8659-44a9-be11-50b82f6e1412",
status: "406",
title: "The specified Accept header value does not contain any supported media types.",
detail: "Please include 'application/vnd.api+json' in the Accept header values."
}
]
}```

So GET requests currently need to have the `application/vnd.api+json`  request header

AFAIK this is not how the system used to work?
...

## Environment

- JsonApiDotNetCore Version: 
- Other Relevant Package Versions:
@bart-degreed
Copy link
Contributor

bart-degreed commented May 26, 2020

I believe your observations are not correct. Omitting an Accept header works, but sending one or multiple that are all incompatible (for example text/html, which browsers may use), the HTTP protocol states to respond with an error if none of the requested media types are available. This is called content negotiation.

@wayne-o
Copy link
Contributor Author

wayne-o commented May 26, 2020 via email

@bart-degreed
Copy link
Contributor

Yes, there was no content negotiation happening before. Now you can send headers like application/* which would match too. This was addressed in #731. I'll add it to the list of changes,

@wayne-o
Copy link
Contributor Author

wayne-o commented May 26, 2020 via email

@fgm1477
Copy link

fgm1477 commented Apr 10, 2021

I'm getting the same response while specifying in postman the contentType 'application/json'. What do I need to do to accept that type of input formatter in the post. I would also need to have the ability to send the body like this.

{
"conditionCode": "tst",
"conditionName": "test",
"conditionNameSpanish": "test spanish",
"createdBy": 1,
"updatedBy": 1
}

@bart-degreed
Copy link
Contributor

@wayne-o We fixed a bug in v4.1.1 which makes GET requests work in Chrome now, because Chrome includes */* in its list of Accept headers, which matches anything. We failed to properly parse such a comma-separated list in the past.

@fgm1477 If you don't want to comply with the json:api specification (which requires all messages be encoded using application/vnd.api+json media type and requires a fixed body format instead of free-format json), then this library does not fit your needs. Our goal is to implement the spec correctly, not make up our own.

@wayne-o
Copy link
Contributor Author

wayne-o commented Apr 12, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants