0

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?

Any assistance would be highly appreciated!

8
  • Did you try to quote url: curl --data-binary @/opt/somefile.xml "http://1.2.3.4/gateway/submit?source=FOO&conversationid=1234567"?
    – Lety
    Nov 7, 2014 at 0:32
  • Yes, as a matter of fact I did. I tried both double as well as single quotes. I even tried using '\&' instead of '&'. The funny thing is that if I change the URL slightly, and make it curl --data-binary @/opt/somefile.xml "1.2.3.4/httpgateway/…" (Changed 'gateway' to 'httpgateway'), I do not get the Bad URL error anymore. I now get a 404 Not Found error, which probably means that the error has something to do with the URL rather than the syntax of the cURL command. Any thoughts on what could be going on? Is the 400 error server generated? Nov 7, 2014 at 8:49
  • Did you try: curl --data-binary @/opt/somefile.xml -d "source=FOO&conversationid=1234567" http://1.2.3.4/gateway/submit
    – Lety
    Nov 7, 2014 at 10:33
  • Thanks, Letzia! I do remember trying curl --data-binary @/opt/somefile.xml --data-binary source=FOO&conversationid=1234567 h t t p : //1.2.3.4/gateway/submit; but to no effect. Of course I did not add the quotes around the "source-FOO..." and I used --data-binary instead of just '-d'. I will try this out Monday and let you know if it worked. Nov 8, 2014 at 22:10
  • Sorry, I did not read well your comment. The error you got 404 Not found means that you reach server but page was not found, in other word, url doesn't match any resource on server. The first error was a curl error and double quote url fix it.
    – Lety
    Nov 9, 2014 at 16:38

1 Answer 1

1

I was able to figure out the problem. The answer to this question was given early on in the discussion by Letizia but the problem was in the Syntax of the URL that I was passing. Apparently, the

...submit?source=FOO&conversationid=1234567

But in actuality I need to pass 'I' (Capital I, instead of small i). It was a typo error and that took more than a week to resolve!

However, the command was wrong otherwise as well because the 'quotes' (Single Quotes) were missing.

You must log in to answer this question.

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