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
2233 questions
10720
votes
36 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
  • 215,718
  • 61
  • 207
  • 286
1349
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
  • 62,644
  • 16
  • 111
  • 180
877
votes
18 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
  • 12,874
  • 5
  • 31
  • 43
584
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
  • 32,648
  • 12
  • 45
  • 77
504
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
  • 18,426
  • 11
  • 59
  • 85
381
votes
7 answers

Setting mime type for excel document

MS Excel has the following observed MIME types: application/vnd.ms-excel…
Subramanian
  • 4,892
  • 5
  • 23
  • 23
329
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,010
  • 29
  • 124
  • 204
312
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,201
  • 5
  • 26
  • 50
261
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
  • 14,662
  • 14
  • 59
  • 100
195
votes
2 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 webRequest.ContentType = "application/x-www-form-urlencoded";
Prithvi Raj Nandiwal
  • 2,564
  • 3
  • 19
  • 33
192
votes
10 answers

Passing headers with axios POST request

I have written an axios POST request as recommended from the npm package documentation like: var data = { 'key1': 'val1', 'key2': 'val2' } axios.post(Helper.getUserAPI(), data) .then((response) => { dispatch({type: FOUND_USER,…
Jagrati
  • 8,910
  • 7
  • 30
  • 42
182
votes
12 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
177
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,635
  • 4
  • 24
  • 43
161
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
  • 50,836
  • 73
  • 238
  • 351
160
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,603
  • 2
  • 5
  • 7
1
2 3
99 100