cURL / Mailing Lists / curl-users / Single Mail

curl-users

Issue in using curl to post to a url-Kindly help

From: mohit huria <huriamohit_at_rediffmail.com>
Date: 27 May 2010 13:55:32 -0000

Hi,

I am using curl to hit a url using http in solaris 10 using commandline, I want to transfer an attachment (using multipart curl -F or any other method if exists) also as a part of the request. kindly help me with the syntax. I am using below command:

When I use below, I get succesful response

Code:
/usr/local/bin/curl -v http://153.88.xxx.xx:80/AttachmentHandler/inboundAttachmentProcessor.aspx -A "Jakarta Commons-HttpClient/3.0"
 --header "Accept: text/xml" -H "Content-Type: multipart/related; type=text/xml" -d "@mm.xml"

but with below commands where I am trying to send an attachment named test.txt I get "Root element is missing"

Code:

/usr/local/bin/curl -v http://153.88.xxx.xx:80/AttachmentHandler/inboundAttachmentProcessor.aspx -A "Jakarta Commons-HttpClient/3.0" --header "Accept: text/xml" -H "Content-Type: multipart/related; type=text/xml" -f "file=mm.xml"

OR

/usr/local/bin/curl -v -X POST http://153.88.xxx.xxx:80/AttachmentHandler/inboundAttachmentProcessor.aspx -A "Jakarta Commons-HttpClient/3.0" -H "Content-Type: multipart/mixed; boundary=74592b13-e90b-49a3-a1bb-54f7341cc1ce" -T tt.xml --data-binary "@test.txt"

OR

 /usr/local/bin/curl -X POST http://153.88.xxx.xxx:80/AttachmentHandler/inboundAttachmentProcessor.aspx -A "Jakarta Commons-HttpClient/3.0" --header "Accept: text/xml" -H "Content-Type: multipart/related; type=text/xml" -d "@mm.xml" -T test.txt

Where , Test.txt is any attachment having some text AND Mm.xml is a valid xml and it tests fine without any attachment.

I've also tried merging mm.xml and test.txt using boundary mentioned in command but that also doesn't work

It looks like below:

--bounday text--
mm.xml text
--boundary text
Test.txt text
--boundary text

In case you want to try this you can login to 150.236.15.4 using ssh client in citrix. Credentials arsadm/arsadm

Thanks & Regards,
Mohit

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-05-27