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?

1 Answer 1


The & is interpreted by the shell you should use quotes (') around the URL:

curl --data-binary @/opt/somefile.xml ''
  • Thank you Anthon, for you answer. I will try this out and let you know if that worked. One thing though, I did run the curl command with just the URL and it gave me a 'Test Message' response from the server. I assume the creators of the server put that response there to let us know that the server did get our message. I used curl h t t p:// If '&' was interpreted by the shell then it should have given me the same error right? Commented Nov 6, 2014 at 20:08
  • Also, I hope I do not have the specifically tell the curl that I am uploading an XML file. I read somewhere that curl generally auto-recognizes the file/protocol types. Commented Nov 6, 2014 at 20:14
  • @SeemantShankar Not necessarily the same error. The URL is cut of at &, so essentially your using curl but since you did not provide POST data where the code that processes it expects it that causes the differense. If you use the same line as the initial in your Q, cut of at & then you should get the Bad URL again. And with the second URL from your Q also cut of you should get Test Message again
    – Anthon
    Commented Nov 6, 2014 at 20:19
  • Thanks Anthon! I want to upvote your answer but am not able to since I am new and do not have enough reps :( Commented Nov 6, 2014 at 20:30
  • @SeemantShankar If this answer solves your issue please take a minute and click the check mark under the vote count to the left, this will signify to everyone that your issue's been resolved and is the way that thanks are expressed in the site.
    – terdon
    Commented Nov 6, 2014 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .