Questions related to the HTTP Accept header, which defines the content types the client advertises it will accept.
Questions tagged [http-accept-header]
79 questions
3
votes
0 answers
What is the meaning of q=0.8;application/json;q=0.9 in Header
I have this doubt related with this SO answer. The solution is to simply included
q=0.8;application/json;q=0.9
as 'Accept' in the Request Header. But what is the meaning of this expression? I can see that the semicolon is used twice and coma is…

nanospeck
- 3,388
- 3
- 36
- 45
3
votes
1 answer
How to interpret multiple Accept-* headers
My reading of RFC 2616 hasn't answered my question:
How should a server interpret multiple Accept, Accept-Encoding, Accept-Language, etc, headers?
Granted, this should generally be a rare occurrence, but far be it from me to assume every HTTP client…

Jonathan Hall
- 75,165
- 16
- 143
- 189
3
votes
0 answers
Create a custom annotation for Symfony routes to check for HTTP Accept header in request
My controllers return different content types with respect to theHTTP Accept header sent by the client. At the moment on a high level my controllers follow this pattern:
/**
* @Route("/SomePath")
* @Method({"GET"})
* @param Request $request The…

user2690527
- 1,729
- 1
- 22
- 38
2
votes
2 answers
How to configure ASP.NET Core Web API to only accept `application/json`?
I would like to configure my ASP.NET Core Web API using .NET 6 to only accept application/json as the accept header value.
How can I configure that?

tRuEsAtM
- 3,517
- 6
- 43
- 83
2
votes
1 answer
nginx error pages based on accept header do not work for json requests
I'm trying to build a nginx-based maintenance mode application, that catches all requests to my applications and returns a predefined response as a 503.
I currently have applications requesting json responses as well as users accessing the pages…

Max N.
- 993
- 1
- 12
- 31
2
votes
0 answers
HTTP Accept header with specific ZIP content
We are developing a REST API that can return a zip file. The content of the zip file can be in CSV or EXCEL format. How should the Accept header describe the two scenarios?
Accept=application/zip;format=csv
Accept=application/zip;format=excel
Is…

TXdev
- 85
- 11
2
votes
4 answers
How does Spring know to convert return object to JSON and not XML or any other format?
Consider the following:
@GetMapping("/accounts/{id}")
@ResponseBody
public Account handle() {
return new Account("1", "sample");
}
There is no Accept header specified in the request, but still the response is by default converted to JSON when…

Daud
- 7,429
- 18
- 68
- 115
2
votes
0 answers
HttpGet returns 406 error after setting Accept header
I have a url with ending &filename=xxxx after hitting it through browser, it redirects to some XXX url start downloading the expected zip file.
When I try to hit the same url through Java code, it reutrns 406 Not Acceptable.
After search in…

aarav
- 230
- 1
- 4
- 21
2
votes
1 answer
C# GitHub SCIM API // Difference between cURL and HttpClient
I'm facing a strange error with the usage of the GITHUB API.
When I contact them with cURL it's like:
curl.exe -H "Accept: application/vnd.github.cloud-9-preview+json+scim" -H "Authorization: Bearer TOKEN"…

Ziba Leah
- 2,484
- 7
- 41
- 60
2
votes
1 answer
Which media type should be chosen from HTTP Accept header when they have the same specifity, quality and level?
As you know you can add multiple media types to the HTTP Accept header. When it comes to the question "What type should the server return?" most explanations and the spec as well seem to only explain the algorithm to select the "preferred" media…

Pipo
- 5,623
- 7
- 36
- 46
2
votes
2 answers
Default "Accept" header value for Asp.Net Web API
If one omits the Accept header in a request to an Asp.Net web API the server will return (415) Unsupported Media Type
I am looking for a way to force the API to assume a default return type (in my case, application/json) when the request does not…

Jimbo
- 22,379
- 42
- 117
- 159
2
votes
1 answer
Does HTTP Content Negotiation apply to error messages?
If a client sends an Accept header of application/xml, should the body of any error message (e.g. 500) also be xml? Or does the Accept header only apply to 200-level responses?

jaco0646
- 15,303
- 7
- 59
- 83
2
votes
1 answer
Warning when setting window.location to download a file
I am setting the window.location to download a file ("/foo/bar"). Now, the download works in google chrome, but it emits this warning:
Resource interpreted as Document but transferred with MIME type application/csv:
These are the response headers…

sveri
- 1,372
- 1
- 13
- 28
2
votes
2 answers
Serving HTML application pages and JSON data in REST
In a RESTful application, is it a good idea to use a "resource" URL to serve up both JSON data and a page to access the data? If not, how should I differentiate the two things?
Suppose I have a page /routes and I have a page to list all routes.…

rink.attendant.6
- 44,500
- 61
- 101
- 156
1
vote
0 answers
Does Laravel automatically process the Accept Headers such that it chooses the best route to match the response format if there are multiple?
I was doing some testing and debugging and ran into an 'observation' that I was sort of unaware of.
The observation was that the Laravel framework intelligently chooses the 'proper' route if I have multiple handlers for the same route, one of which…

SScotti
- 2,158
- 4
- 23
- 41