Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl setting Content-Type incorrectly

Tags:

curl

youtube

I am running a curl operation on the command line and am having trouble forcing the header to set as XML. I use the -H option to force the Content-Type to be xml, however, once I run the command I can see that the header is sent as urlencoded which is tainting one of the data values that I'm sending. Can someone explain to me why the Content-Type is always reset back to "application/x-www-form-urlencoded" instead of "application/atom+xml"?

I am using this to retrieve an upload token from YouTube using their API. I have no trouble retrieving an authentication token using a similar command.

curl -S -v  --location http://gdata.youtube.com/action/GetUploadToken -H Content-Type= text/xml --data content=some xml content here --data GoogleLogin auth="DQAAAHU.....TiU95NXYSLFFENTbNQUy....NjfFoC0nyEKaz-ejEkA_w" -H X-Gdata-Key: key=AI39si5EQyo-_L......78eL80r-MooHXtrA48R82AShoQ -H Content-Length=445 
like image 942
Miriam P. Raphael Avatar asked Nov 16 '09 22:11

Miriam P. Raphael


People also ask

How do I change the content-type in curl?

To send the Content-Type header using Curl, you need to use the -H command-line option. For example, you can use the -H "Content-Type: application/json" command-line parameter for JSON data. Data is passed to Curl using the -d command-line option.

What is content-type in curl?

Content-Type - Everything curl. Content-Type. POSTing with curl's -d option will make it include a default header that looks like Content-Type: application/x-www-form-urlencoded . That is what your typical browser will use for a plain POST. Many receivers of POST data do not care about or check the Content-Type header.


1 Answers

I think you want to specify

-H "Content-Type:text/xml" 

with a colon, not an equals.

like image 182
qedi Avatar answered Oct 23 '22 01:10

qedi