3

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 http://1.2.3.4/gateway/submit?source=FOO&conversationid=1234567

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...

curl http://1.2.3.4/gateway/submit?source=FOO&conversationid=1234567

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?

3

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

curl --data-binary @/opt/somefile.xml 'http://1.2.3.4/gateway/submit?source=FOO&conversationid=1234567'
  • 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://1.2.3.4:8081/gateway/submit?source=FOO&conversationid=1234567. If '&' was interpreted by the shell then it should have given me the same error right? – Seemant Shankar Nov 6 '14 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. – Seemant Shankar Nov 6 '14 at 20:14
  • @SeemantShankar Not necessarily the same error. The URL is cut of at &, so essentially your using curl http://1.2.3.4/gateway/submit?source=FOO 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 Nov 6 '14 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 :( – Seemant Shankar Nov 6 '14 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 Nov 6 '14 at 20:35

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.