Can I set Content-Type via curl on the command line without adding "border = ------"?
I am sending command line curl command to web server. The web server only accepts content of type application / xml or application / json. My curl command (slightly edited):
curl -k --cert certfile --form "fileupload=@test.xml" --cacert cacert.pem https://IP:PORT/v1/all/3131 --header "allowed-domains: foo.net" -H "Content-Type:application/xml"
I found that the server is rejecting this with the following:
POST load request has invalid type application/xml; boundary=----------------------------dc1435dd0d36
The problem is that the server doesn't recognize
"boundary=----------------------------dc1435dd0d36"
Is there a way to tell curl not to include this? Or is it a server bug?
I found a related question about this, but it only addressed programs that can set curl options via curl_setopt. Is there a way to do this on the command line? See this earlier question:
PHP cURL Content-Length and Content-Type are wrong
Thanks in advance for your help!
source to share
If you want to send application/xml
, you must use --data
instead of --form
which is sending multipart/form-data
. In your case, this should be the content of the file, not the actual file you want to send. Like this:
curl -k --cert certfile --data "@test.xml" --cacert cacert.pem https://IP:PORT/v1/all/3131 --header "allowed-domains: foo.net" -H "Content-Type:application/xml"
source to share