I have this really typical problem. I have an XML file that I have to post to a server. I was told by the network engineer of that site to use the cURL function. The function that he provided to me was...

curl --data-binary @/opt/somefile.xml

When I run this command I keep getting the error "Bad URL, returning 400 status"

I have been stuck on this problem for quite a while now and I am getting seriously frustrated. I have tried running...


and I am getting a response from the machine "Test Message" along with some identification parameters of the host system. What this would probably mean that the URL of the destination is OK and it is being accessed via the cURL command.

Are there any special requirements for sending XML files via --data-binary? Does the XML need to be formatted in a special way? Is the syntax of the cURL command incorrect?

Any assistance would be highly appreciated!

  • Crazy idea: Ever consider wrapping that URL in quotes so the command looks like this: curl --data-binary @/opt/somefile.xml "". – JakeGould Oct 10 '15 at 5:48

HTTP Code 400 Bad Request means there was something wrong with the request you sent. This can be for any reason that the developer has programmed. It is meant to indicate user error.

If this URL is meant to receive XML it may just mean you are missing the Content-Type header. To specify that header:

curl --header "Content-Type:application/xml"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.