Curl XPOST errors not supported 406

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?

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 and click the copy as cUrl button, you will see how to add the proper header to your curl calls.

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?

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!