Questions tagged [content-type]

The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET.

The Content-Type entity-header field indicates the media type (or MIME type) of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET.

Content-Type   = "Content-Type" ":" media-type

An example of the field for HTML documents is:

Content-Type: text/html; charset=ISO-8859-4

For a PNG file, it would be:

Content-Type: image/png

Source: http://www.w3.org/

HTTP Specification : Section 14 : Header Field Definitions

Wikipedia articles:

  1. MIME
  2. Internet media type
2280 questions
11086
votes
37 answers

What is the correct JSON content type?

I've been messing around with JSON for some time, just pushing it out as text and it hasn't hurt anybody (that I know of), but I'd like to start doing things properly. I have seen so many purported "standards" for the JSON content…
Oli
  • 225,853
  • 62
  • 212
  • 293
1393
votes
3 answers

Proper MIME media type for PDF files

When working with PDFs, I've run across the MIME types application/pdf and application/x-pdf among others. Is there a difference between these two types, and if so what is it? Is one preferred over the other? I'm working on a web app which must…
friedo
  • 64,008
  • 16
  • 112
  • 180
972
votes
20 answers

How do you set the Content-Type header for an HttpClient request?

I'm trying to set the Content-Type header of an HttpClient object as required by an API I am calling. I tried setting the Content-Type like below: using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new…
mynameiscoffey
  • 13,884
  • 5
  • 32
  • 44
632
votes
10 answers

HTML Input="file" Accept Attribute File Type (CSV)

I have a file upload object on my page: with the following excel files on my desktop: file1.xlsx file1.xls file.csv I want the file upload to ONLY show .xlsx, .xls, & .csv files. Using the accept attribute,…
Dom
  • 35,163
  • 12
  • 47
  • 79
549
votes
5 answers

What MIME type should I use for CSV?

I've seen application/csv used and also text/csv. Is there a difference? Does it matter which as long as the request matches something that's available? Are they interchangeable?
Steve Dunn
  • 19,546
  • 11
  • 60
  • 87
397
votes
6 answers

Setting mime type for excel document

MS Excel has the following observed MIME types: application/vnd.ms-excel…
Subramanian
  • 5,122
  • 5
  • 23
  • 24
351
votes
4 answers

What are all the possible values for HTTP "Content-Type" header?

I have to validate the Content-Type header value before passing it to an HTTP request. Is there a specific list for all the possible values of Content-Type? Otherwise, is there a way to validate the content type before using it in an HTTP request?
Awesome
  • 4,661
  • 6
  • 30
  • 54
340
votes
17 answers

Jquery - How to make $.post() use contentType=application/json?

I've noticed that when using $.post() in jquery that the default contentType is application/x-www-form-urlencoded - when my asp.net mvc code needs to have contentType=application/json (See this question for why I must use application/json: ASPNET…
JK.
  • 20,541
  • 31
  • 127
  • 206
270
votes
4 answers

Difference between application/x-javascript and text/javascript content types

What is the difference between these headers? Content-Type: application/javascript Content-Type: application/x-javascript Content-Type: text/javascript Which one is best and why? Please do not say they are identical - if they were identical there…
Obmerk Kronen
  • 15,115
  • 16
  • 63
  • 104
213
votes
3 answers

What are the differences between application/json and application/x-www-form-urlencoded?

What is the difference between request.ContentType = "application/json; charset=utf-8"; and request.ContentType = "application/x-www-form-urlencoded";
Prithvi Raj Nandiwal
  • 2,744
  • 3
  • 19
  • 33
193
votes
6 answers

Do I need a content-type header for HTTP GET requests?

As far as I understood there are two places where to set the content type: The client sets a content type for the body he is sending to the server (e.g. for post) The server sets a content type for the response. Does this mean I don't have to or…
Martin Flucka
  • 2,825
  • 5
  • 26
  • 43
186
votes
13 answers

Where's my JSON data in my incoming Django request?

I'm trying to process incoming JSON/Ajax requests with Django/Python. request.is_ajax() is True on the request, but I have no idea where the payload is with the JSON data. request.POST.dir contains this: ['__class__', '__cmp__', '__contains__',…
user122299
171
votes
9 answers

Mail multipart/alternative vs multipart/mixed

When creating email messages you are supposed to set the Content-Type to multipart/alternative when sending HTML and TEXT or multipart/mixed when sending TEXT and attachments. So what do you do if you want to send HTML, Text, and attachments? Use…
Xeoncross
  • 52,774
  • 75
  • 248
  • 359
169
votes
3 answers

Content-Type header [application/x-www-form-urlencoded] is not supported on Elasticsearch

I used to have ElasticSearch 5.2, and just upgraded to 6.0. I am trying to create an index template following guide here, but got error Content-Type header [application/x-www-form-urlencoded] is not supported My query is curl -X PUT…
Barry Leishman
  • 1,693
  • 2
  • 6
  • 7
169
votes
7 answers

Create request with POST, which response codes 200 or 201 and content

Suppose I write a REST service whose intent is to add a new data item to a system. I plan to POST to http://myhost/serviceX/someResources Suppose that works, what response code should I use? And what content might I return. I'm looking at the…
djna
  • 53,570
  • 11
  • 71
  • 113
1
2 3
99 100