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
0
votes
1 answer
Should I use the accept http header or a more explicit rest api resource to define the data format requested by the client?
Let's say I have an API like: /api/v1//modify?txtUri={a-text-file-uri-goes-here} which filters and modify a given text file located at a given URI and returns in the payload response the filtered text file based on some internal business rules.
At…

Maxwell
- 105
- 7
0
votes
2 answers
Return "text/plain" while ignoring 'Accept' header
I have this piece of code:
@RequestMapping(value = "/test", produces = "text/plain")
@ResponseBody
public Object test() {
return "true";
}
And what I want is returning in this case "true" with 'text/plain' type even when my accept header says…

Patryk Chmiel
- 1
- 1
- 2
0
votes
1 answer
How to handle error responses in a REST endpoint that accepts different Accept header values.
I'm trying to add a new content type to a REST endpoint. Currently it only returns json but I now need to be able to return also a CSV file.
As far as I know, the best way to do this is by using the Accept header with value text/csv and then add a…

Juan Vega
- 1,030
- 1
- 16
- 32
0
votes
1 answer
How does my browser display a pdf when it didn't specify that's something it would accept?
I'm writing a simple HTTP server that will serve content from the file system.
I'm a little confused as to how the client and server negotiate content type.
After doing some research, I found that Content-Type specifies the content type of the HTTP…

toastedDeli
- 570
- 5
- 28
0
votes
1 answer
Versioning as part of Accept header in springboot
As part of development I would like to maintain the two different versions of response.I have used produces key word as part of request mapping to differentiate the implementation.
when version = 1.0 the method for first implementation should be…
0
votes
1 answer
Accept header in ruby rest-client I believe causes return of an error code 404
I am passing the following request to ruby rest-client gem;
RestClient::Request.execute(method: :get,
url: Config['site_url'] + path,
verify_ssl: OpenSSL::SSL::VERIFY_NONE,
…

Suley Mahmoud
- 35
- 8
0
votes
1 answer
How to specify that I can accept all media types in the Accept header?
I want to send an HTTP request and I want to specify that I can accept all media types in the Accept header, is the following correct:
Accept: */*

Steve
- 691
- 5
- 18
0
votes
1 answer
HTTP Content Negotiation with accept
Could someone help me clarify what the number values of the q parameter represent. I know that the values are used to select your preference but what I do not understand is how the numbers are used. For example in the below code would my preference…

TyAnthoney
- 278
- 4
- 12
0
votes
2 answers
How to determine the right Accept Content-Type with ExpressJS
I'm having trouble to distinguish an ajax call from other calls in ExpressJS.
As far as I understand, I can use request.accepts('json') to identify a json request?
The problem is - apparently, every call accepts everything!
app.get( '*',…

Katai
- 2,773
- 3
- 31
- 45
0
votes
1 answer
REST HTTP Accept header mime type for single vs plural
I would like to use the vendor mime type standard in the accept header to handle REST resource requests and versions. We expose a set of get methods for some resources, one returning an array of all or a subset of resources from a search or similar,…

Matthew Artz
- 31
- 2
0
votes
1 answer
Using Accept request header to branch on JSON vs html
Looking at using the http Accept header to branch if the server should return html or json of a resource. I was thinking of just using:
Accept: application/json
But further research and reading the GitHub API, the standard seems to be:
Accept:…

Justin
- 42,716
- 77
- 201
- 296
0
votes
1 answer
Return different MIME types based on Accept header parameter on Amazon AWS API Gateway
Could you explain how to setup Amazon AWS API Gateway to return different documents based on the request HTTP Accept header?
Two examples:
curl --request GET 'http://api.sample.com/v1/hello' --header 'Accept: text/HTML'
Hello,…

rjobidon
- 3,055
- 3
- 30
- 36
0
votes
1 answer
Required steps for implementing localization in a MVC application in C#
I need to implement localization for resource (.resx) messages in a MVC application, but have been failing to do so.
Reviewing the steps I am following:
1. Create a Localization project and add as many resource (.resx) files as the languages you…

Veverke
- 9,208
- 4
- 51
- 95
0
votes
0 answers
How do I modify the accept headers for a GET request (outside of ajax) on the client side?
I have a download to Excel button on a page whose intent is to call the exact same URL, but with the Request Header set to "application/ms-excel".
Currently, I am faking it, by calling another URL, then adjusting the headers and then forwarding to…

JL Peyret
- 10,917
- 2
- 54
- 73
0
votes
1 answer
Media subtype parameters in Accept header parameters
The Accept HTTP header is able to specify parameters to each Media type that it references.
text/html;level=2;q=0.4, */*;q=0.5
Is it possible to quote a parameter such that it can include otherwise non-allowed characters?
This is mostly a thought…

Ryan Hiebert
- 571
- 1
- 5
- 17