Questions tagged [http-accept-header]

Questions related to the HTTP Accept header, which defines the content types the client advertises it will accept.

79 questions
46
votes
3 answers

C# Add Accept header to HttpClient

What is the difference between these two calls? My end goal is to have Accept: application/json sent over the wire, not to append to some default set of other MIME types. HttpClient client = new…
evilSnobu
  • 24,582
  • 8
  • 41
  • 71
12
votes
1 answer

ASPNetCore API Content negotiation not working

I'm trying to get my api set up so it will respond with with XML or JSON depending upon the Accept header. I'm following the tutorial by Shawn W: https://wildermuth.com/2016/03/16/Content_Negotiation_in_ASP_NET_Core It says to add a package to:…
9
votes
1 answer

Why does rails not recognize `Accept: application/json` in the request header?

I have some frontend javascript that makes an asynchronous http request to my backend rails server. On the frontend I am not using XHR (I use axios, although that's not entirely relevant to the question). In the request, I set the following to tell…
abhchand
  • 515
  • 6
  • 13
8
votes
2 answers

Spray routing: How to respond with different content-types?

In spray I would like to respond with different content-types, depending on the given Accept header. I've seen a couple of suggestions in the question by rompetroll, but I would like to hear if there are any canonical way of doing it (i. e. simple…
Jens Egholm
  • 2,730
  • 3
  • 22
  • 35
7
votes
0 answers

Reading browser's Accept header in Javascript

While it's possible to get the browser's User-Agent in Javascript via navigator.userAgent, is it likewise possible to get the browser's Accept header without performing a HTTP request?
Matt Borja
  • 1,509
  • 1
  • 17
  • 38
7
votes
2 answers

How to specify to accept multipart/related content type with particular content types for body part in the accept header field

RFC 7231 - HTTP/1.1 Semantics and Content, 5.3 Content Negotiation does not define how to specify to accept a multipart/related content type with particular content types for body parts in the accept header field. For instance, how to express…
6
votes
1 answer

How to config spring to ignore invalid Accept header?

I'm using spring to build my web app. In my custom WebMvcConfigurationSupport class, I setup basic ContentNegotiationConfigurer like following: @Override public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { …
Void Main
  • 2,241
  • 3
  • 27
  • 36
5
votes
1 answer

GET request - desired response format in parameter or Accept header

I am working on an ASP.Net Web API 2 RESTful web service for importing and exporting data from my database. For my export method, the client has several options for exporting data in different formats (e.g. pdf, xml, etc.). I am trying to…
Brian
  • 2,702
  • 5
  • 37
  • 71
5
votes
3 answers

Add Accept header to JQuery AJAX GET (via JSONP) request

I'm trying to add an accept header to a jQuery AJAX GET request which uses the "jsonp" dataType, but for some reason it's not working. Here's my code thus far. var e4json = JSON.stringify( { "thomas_smith106" :…
adeiji
  • 550
  • 1
  • 3
  • 13
4
votes
2 answers

NotAcceptableException (HTTP 406 Not Acceptable) but no apparent error from MessageBodyWriter

In a webapp implemented as a Jetty container, we have a custom javax.ws.rs.ext.MessageBodyWriter annotated with @Singleton @Provider @Produces( "application/rss+xml" ) We also have a resource which works just fine. The get() method is annotated…
Stewart
  • 17,616
  • 8
  • 52
  • 80
4
votes
0 answers

HTTPWebRequest Not Adding Accept Header

I'm trying to parse a web page and one of the requirements in the request is setting the appropriate Accept Header. I've verified it doesn't work without setting this via Postman. So I am trying to set the Accept Header in a GET request via…
4
votes
2 answers

Is '*' a valid wildcard for a content type according to HTTP spec?

We're using the Jersey reference implementation of Jax-RS. The Jax-RS client implementation of Jersey is appending a default accept header to the request if no accept header is specified. The default accept header looks like this: Accept: text/html,…
Gerald Mücke
  • 10,724
  • 2
  • 50
  • 67
4
votes
1 answer

Are weight values required in an Accept Header with multiple values?

Per the spec, the HTTP Accept header can have multiple values, like so: Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8 Source My question is this: do Accept headers with multiple values need to have at least one weight?…
teuber789
  • 1,527
  • 16
  • 28
4
votes
2 answers

GET call on REST API with Accept as text/csv and content-Type as application/json. In what format should the reponse be?

GET call on REST API with Accept as text/csv and content-Type as application/json. In what format should the reponse be? Should the response be in JSON format or in CSV format?
user2921591
  • 51
  • 1
  • 1
  • 6
4
votes
1 answer

Using curl with a --config file

I've been making curl requests to a long URL and saved the URL in a file named "url.txt". I then query that URL using the following command... http://curl.haxx.se/docs/manpage.html#-K curl -K ../url.txt The url.txt file in this case contains the…
Michael
  • 71
  • 1
  • 1
  • 3
1
2 3 4 5 6