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
1
vote
2 answers
Spring Boot: Add new Extension-AcceptHeader mappings
Within a normal Spring Application, I have:
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
@Override
protected Map getDefaultMediaTypes() {
Map mediaTypes =…

Benjamin M
- 23,599
- 32
- 121
- 201
1
vote
3 answers
Custom accept header not working on Windows Phone 8
I have a class in a Portable Class Library (targeting .NET 4.5 and Windows Phone 8.1) that uses the HttpClient (System.Net.Http.HttpClient) class to post a string to a web service. The service requires that I set the Accept header in the request to…

Tom Faltesek
- 2,768
- 1
- 19
- 30
1
vote
1 answer
Spring MVC return json only 406 with ContentNegotiationManagerFactoryBean
I want only JSON response to be turned for any request that is made to http://localhost:8090/home/home/home2 for a servlet context as "home".
The configuration that I have set is to return default as "JSON" response if there are no accept headers.
I…

NNikN
- 3,720
- 6
- 44
- 86
0
votes
0 answers
HttpURLConnection - Obtain both JSON and PDF from the same request
I have a web service API call that returns BOTH:
First part is document metadata in the form of JSON (application/JSON)
and in the same response returns PDF bytes (application/pdf)
If HttpURLConnection.setRequestProperty("Accept",…

Sam G
- 1
- 1
0
votes
1 answer
react-dropzone error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'
"react-dropzone": "^14.2.2"
const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: {
"image/*": [".jpeg", ".png", ".jpg"],
},
Error:
MediaField.tsx:266:5 - error TS2322: Type 'string | { "image/*": string[]; }'…

Kok How Teh
- 3,298
- 6
- 47
- 85
0
votes
1 answer
Accept type is invalid , INVALID_ACCEPT_TYPE.GMP_ITEM_QUERY_API ( Walmart ItemSearch API Error )
Searching Item from Walmart Catalog Error 406 Not Acceptable
"code": "INVALID_ACCEPT_TYPE.GMP_ITEM_QUERY_API"
"info": "Accept type is invalid."
The Walmart Item Search API allows us to query the Walmart.com global product catalog by item keyword,…

Asad Ali
- 3
- 1
0
votes
1 answer
httpmediatypenotacceptableexception spring mvc
I am trying to return an image as shown here https://www.baeldung.com/spring-mvc-image-media-data
All methods that are shown there are working properly, except for the last one.
@ResponseBody
@RequestMapping(value = "/image-resource", method…
0
votes
1 answer
How to check if browser accepting webp images?
I am using $_SERVER['HTTP_ACCEPT'] and after I can check if browser supporting webp images. But when I sending ajax request and trying to get the $_SERVER['HTTP_ACCEPT'] it's returning application/json, text/javascript, */*; q=0.01.
How can I check…
0
votes
2 answers
Dynamic 365 API only returns XML despite Request for JSON
I am using Postman to query a Dynamics 365 Business Central (BC) API. The API is returning XML and I am trying to get it to return JSON. The Microsoft page that gives an example shows the response as being in JSON format.
I tried added my own…

webworm
- 10,587
- 33
- 120
- 217
0
votes
0 answers
ASP.NET Core Setting Response.ContentType via IActionFilter results in 406 Not allowed
I'm using IActionFilter.OnActionExecuted (ASP.NET Core 3.1) to set context.HttpContext.Response.ContentType with a media type and charset, e.g. application/json; charset=utf-8.
However when setting the ContentType property the response status code…

codesoep
- 11
- 1
0
votes
0 answers
How to remove and add new Accept header to Spring boot Rest Template?
I'm consuming a GraphQL Service, it is returning 406 Not Acceptable if the Accept header is text/plain.
It is expecting to Accept as application/json
So I tried override the RestTeamplate Headers. However it seems the Accept header test/plain is…

rram
- 2,004
- 5
- 24
- 37
0
votes
1 answer
What is the javax.ws.rs MediaType we need to use for JWT response
What is the MediaType we can use in @Produces annotation if we are expecting the server to return a JWT response?
for application json we can use,
@Produces({MediaType.APPLICATION_JSON})
But what if we want it to be application/jwt ?
If we use it…

Raveen Athapaththu
- 190
- 1
- 1
- 13
0
votes
1 answer
How to get HTTP request Accept Header in android WebView
Wanted to get WebView browser properties in android.
Able to get properties like navigator.userAgent, screen.width, screen.height etc.
webView.evaluateJavascript("navigator.javaEnabled()", new ValueCallback() {
@Override
…

user1537457
- 109
- 2
- 9
0
votes
0 answers
Tell Spring Boot REST endpoint to allow requests that are missing an Accept header
I have client apps that send a request to an endpoint without an Accept header. The endpoint fails with "Could not find acceptable representation" but I would like the controller to process the request anyway.
I'm writing a Java app that handles…

mcpierce
- 312
- 5
- 16
0
votes
0 answers
REST Template failing to parse a String response with a Colon ( ':' )
I am trying a hit a POST API which is returning a token of the format - "ABC:XYZ". When I am trying to parse this into a String it is not able to do it. I suspect, it is because of the presence of a colon( : ) in the token because of which it is…

Nayan Arora
- 47
- 1
- 7