# Curl XPOST errors not supported 406

**URL:** https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509
**Category:** Elasticsearch
**Created:** [March 28, 2020, 9:13pm UTC](https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509 "2020-03-28T21:13:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ketan\_Chachad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ketan_chachad/32/49908_2.png) [@Ketan\_Chachad](https://discuss.elastic.co/u/Ketan_Chachad)
#### Post date: [March 28, 2020, 9:13pm UTC](https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509/1 "2020-03-28T21:13:41Z")

</div>

I have installed elasticsearch 7.6.1 on an AWS EC2 instance.  
When I give the following curl command from Windows I get a valid JSON response:  
`curl -XGET "http://<EC2-IP>:9200"`  
However when I give the following command:  
`curl -XPOST "http://<EC2-IP>:9200/table_search_index/_doc/<doc_id>" -H 'Content-Type: application/json' -d'{<json_doc>}'`  
I get the error:  
`{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}`

Can anyone tell me what the issue would be?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [March 30, 2020, 2:29pm UTC](https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509/2 "2020-03-30T14:29:12Z")

</div>

you're missing the correct content-type header. As an example, go to the documentation at [https://www.elastic.co/guide/en/elasticsearch/reference/7.6/docs-index\_.html#\_create\_document\_ids\_automatically](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/docs-index_.html#_create_document_ids_automatically) and click the `copy as cUrl` button, you will see how to add the proper header to your curl calls.

---

<div class="post-metadata">

### Author: ![Ketan\_Chachad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ketan_chachad/32/49908_2.png) [@Ketan\_Chachad](https://discuss.elastic.co/u/Ketan_Chachad)
#### Post date: [March 30, 2020, 2:52pm UTC](https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509/3 "2020-03-30T14:52:09Z")

</div>

Thanks for the link.  
I checked the header generated when I clicked on the `copy as cUrl` button.  
The header generated by it was `-H 'Content-Type: application/json'` which is the same header I have mentioned in the command I gave to POST my data.  
So is there any other reason for the failure?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [March 30, 2020, 3:10pm UTC](https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509/4 "2020-03-30T15:10:29Z")

</div>

Given the response I dont think that the option has been passed to curl or properly parsed.

Can you put the output of `curl -v` into a pastebin, this will allow you see check the headers from the request that is sent to elasticsearch?

Thanks!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 27, 2020, 3:12pm UTC](https://discuss.elastic.co/t/curl-xpost-errors-not-supported-406/225509/5 "2020-04-27T15:12:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
