Sponsored Content
Top Forums UNIX for Advanced & Expert Users Issue in Curl to send http POST request with attachment/multipart Post 302422588 by manishmaha on Wednesday 19th of May 2010 12:23:06 AM
Old 05-19-2010
Issue in Curl to send http POST request with attachment/multipart

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) also as a part of the request. If anyone has used kindly help me with the syntax. I am using below command:


Code:


/usr/local/bin/curl -v http://153.88.xxx.xx:80/AttachmentHa...Processor.aspx -A "Jakarta Commons-HttpClient/3.0" --header "Accept: text/xml" -H "Content-Type: multipart/related; type=text/xml" -f "file=mm.xml"
When I use below, I get succesful result but with above command I get "Root element is missing", as I need to send multipart content(i.e. an attachment as well) so I want to use -F option, also let me know how to send attachment also.


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

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Http request in Linux

Hi, i need a guide how to write a script which i can do a http request. Let say the request look like below; http://www.test.com?txid=1&type=service&server=linux I have a list of "txid" (in *.txt) and need to run all "txid" acordingly. So that mean, every transaction i have to refer "txid"... (7 Replies)
Discussion started by: malaysoul
7 Replies

2. UNIX for Dummies Questions & Answers

HTTP request

Can anybody tell about http request processing in shell script..? (3 Replies)
Discussion started by: noufal
3 Replies

3. UNIX for Dummies Questions & Answers

How to send a Head Http request from command line

Ok. I'm testing a new program component that is supposed to speed up our pipeline on the server. What it does is take in HEAD requests and shuffle them off to a different pipeline that is specially designed to handle HEAD requests quickly. The functionality works but now comes the question: how... (3 Replies)
Discussion started by: darkling235
3 Replies

4. Shell Programming and Scripting

How to send XML data using HTTP Post Request

How to hit HTTP Post Request along with sending XML data to a Remote server through command line utility like wget (or anything else). (0 Replies)
Discussion started by: sandeep reddy
0 Replies

5. UNIX for Advanced & Expert Users

Syntax issue in curl for getting a file from http site

Hi All I am using curl in my client environment. We need to pull a file from the libraries site. All the files are having perticular URL which can be used to get the files. Only issue is, when we fire that command , it will take to authentication page 1st. once authentication is succed, it will... (1 Reply)
Discussion started by: prabirkumardhar
1 Replies

6. Shell Programming and Scripting

http request

I am running a website but I still have problems with the "service temporarily unavailable error". I want to make a simple check if the website is up and running. Does anybody has an idea how to do it? (the site is password protected, so you have to add a user and pwd before logging in). ... (2 Replies)
Discussion started by: jurgen
2 Replies

7. Shell Programming and Scripting

Parsing the http post request

Hi, I am trying to write a shell script to parse the post request data that it received to a xml file. Below is the post request data that script is receiving. -----------------------------7dd2339190c8e Content-Disposition: form-data; name="param1" 1... (2 Replies)
Discussion started by: jdp
2 Replies

8. Shell Programming and Scripting

Curl Script - Post a file (multipart/form-data)

Hi All, I am trying to post an xml file (utf-16 encoded) using curl to a REST service. The REST service is expecting 'multipart/form-data' content type. curl -k -i -H "Content-Type=multipart/form-data" -F "filename=@file.xml;type=text/xml" -X POST -u <username>:<password> <endPointURL> ... (0 Replies)
Discussion started by: Anooja G
0 Replies

9. Shell Programming and Scripting

Construct and Send Multipart MIME Mail

Hi, I have requirment in shell script to incorporate multipart email with both html and text. Here am giving the text version. From: any@email.com To: your@email.com Subject: Success Execution - $company - Apps PO File Report Apps PO File Report Summary: #APPS Purchase... (2 Replies)
Discussion started by: kirankumar
2 Replies

10. Web Development

Curl - post form issue

I'm having an issue with curl post form, I dont' understand what I'm mising. I would like to send a post command login/password to a form, quite simple in the paper. URL : http: // <myebsite> / login Here the form source code : <form action="/login_check" method="post"> <input... (3 Replies)
Discussion started by: Fred13
3 Replies
CURLOPT_HTTPPOST(3)					     curl_easy_setopt options					       CURLOPT_HTTPPOST(3)

NAME
CURLOPT_HTTPPOST - specify the multipart formpost content SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HTTPPOST, struct curl_httppost *formpost); DESCRIPTION
Tells libcurl you want a multipart/formdata HTTP POST to be made and you instruct what data to pass on to the server in the formpost argu- ment. Pass a pointer to a linked list of curl_httppost structs as parameter. The easiest way to create such a list, is to use curl_for- madd(3) as documented. The data in this list must remain intact as long as the curl transfer is alive and is using it. Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with CURLOPT_HTTPHEADER(3). When setting CURLOPT_HTTPPOST(3), it will automatically set CURLOPT_NOBODY(3) to 0. DEFAULT
NULL PROTOCOLS
HTTP EXAMPLE
/* Fill in the file upload field. This makes libcurl load data from the given file name when curl_easy_perform() is called. */ curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "sendfile", CURLFORM_FILE, "postit2.c", CURLFORM_END); /* Fill in the filename field */ curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "filename", CURLFORM_COPYCONTENTS, "postit2.c", CURLFORM_END); /* Fill in the submit field too, even if this is rarely needed */ curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "send", CURLFORM_END); AVAILABILITY
As long as HTTP is enabled RETURN VALUE
Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not. SEE ALSO
CURLOPT_POSTFIELDS(3), CURLOPT_POST(3), curl_formadd(3), curl_formfree(3), libcurl 7.54.0 May 17, 2016 CURLOPT_HTTPPOST(3)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy