Reputation: 42100
I would like to use curl
to send an HTTP POST request with a multipart body, which consists of two parts part1
and part2
like this:
Content-Type: multipart/form-data;
boundary=v6jSBESHUN0nHdfaw-GnE4zGVcg0OLfL1
--v6jSBESHUN0nHdfaw-GnE4zGVcg0OLfL1
Content-Disposition: form-data; name="part1"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
abc
--v6jSBESHUN0nHdfaw-GnE4zGVcg0OLfL1
Content-Disposition: form-data; name="part2"
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
xyz
--v6jSBESHUN0nHdfaw-GnE4zGVcg0OLfL1--
Note that the content of part1
is abc
and the content of part2
is xyz
. The charset of part1
is ascii
and the charset of part2
is utf-8
.
I am trying to do it as follows:
curl -X POST -F "part1=abc" -F "part2=xyx" http://myhost/mypost
Unfortunately it did not do the trick. Besides, I did not find to how specify the charset of part2
. How would you suggest send this request with curl
?
Upvotes: 0
Views: 924
Reputation: 16927
You can set the type with ;type=
curl -X POST -F "part1=abc" -F "part2=xyx;type=text/plain; charset=utf-8" http://myhost/mypost
Upvotes: 2