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
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
Can anybody tell about http request processing in shell script..? (3 Replies)
Discussion started by: noufal
3 Replies
3. UNIX for Dummies Questions & Answers
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 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
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
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
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
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
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
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
LEARN ABOUT MOJAVE
curlopt_postfields
CURLOPT_POSTFIELDS(3) curl_easy_setopt options CURLOPT_POSTFIELDS(3)
NAME
CURLOPT_POSTFIELDS - specify data to POST to server
SYNOPSIS
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDS, char *postdata);
DESCRIPTION
Pass a char * as parameter, pointing to the full data to send in a HTTP POST operation. You must make sure that the data is formatted the
way you want the server to receive it. libcurl will not convert or encode it for you in any way. For example, the web server may assume
that this data is url-encoded.
The data pointed to is NOT copied by the library: as a consequence, it must be preserved by the calling application until the associated
transfer finishes. This behaviour can be changed (so libcurl does copy the data) by setting the CURLOPT_COPYPOSTFIELDS(3) option.
This POST is a normal application/x-www-form-urlencoded kind (and libcurl will set that Content-Type by default when this option is used),
which is commonly used by HTML forms. Change Content-Type with CURLOPT_HTTPHEADER(3).
You can use curl_easy_escape(3) to url-encode your data, if necessary. It returns a pointer to an encoded string that can be passed as
postdata.
Using CURLOPT_POSTFIELDS(3) implies CURLOPT_POST(3).
If CURLOPT_POSTFIELDS(3) is explicitly set to NULL then libcurl will get the POST data from the read callback. If you want to send a zero-
byte POST set CURLOPT_POSTFIELDS(3) to an empty string, or set CURLOPT_POST(3) to 1 and CURLOPT_POSTFIELDSIZE(3) to 0.
Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with CURLOPT_HTTPHEADER(3) as
usual.
To make multipart/formdata posts (aka RFC2388-posts), check out the CURLOPT_HTTPPOST(3) option combined with curl_formadd(3).
DEFAULT
NULL
PROTOCOLS
HTTP
EXAMPLE
CURL *curl = curl_easy_init();
if(curl) {
const char *data = "data to send";
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* size of the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 12L);
/* pass in a pointer to the data - libcurl will not copy */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_perform(curl);
}
AVAILABILITY
Always
RETURN VALUE
Returns CURLE_OK
SEE ALSO
CURLOPT_POSTFIELDSIZE(3), CURLOPT_READFUNCTION(3),
libcurl 7.54.0 June 11, 2016 CURLOPT_POSTFIELDS(3)