curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: How to send a POST request by curl same to a httpie request?

From: Nicolas Sterchele via curl-users <curl-users_at_cool.haxx.se>
Date: Fri, 3 Jul 2020 22:03:35 +0200

On 2020-07-03 21:57, Nicolas Sterchele wrote:
>On 2020-07-03 14:30, Peng Yu via curl-users wrote:
>>$ http --form POST localhost:9000 file_at_1.txt
>>
>>The above httpie (https://httpie.org/) command will send the following
>>POST request. Could anybody let me know what is the equivalent curl
>>command to achieve the same HTTP request? Thanks.
>>
>>
>>POST / HTTP/1.1
>>Host: localhost:9000
>>User-Agent: HTTPie/2.2.0
>>Accept-Encoding: gzip, deflate
>>Accept: */*
>>Connection: keep-alive
>>Content-Length: 171
>>Content-Type: multipart/form-data; boundary=36922889709f11dcba960da4b9d51a2e
>>
>>--36922889709f11dcba960da4b9d51a2e
>>Content-Disposition: form-data; name="file"; filename="1.txt"
>>Content-Type: text/plain
>>
>>abc
>>
>>--36922889709f11dcba960da4b9d51a2e--
>>
>>--
>>Regards,
>>Peng
>>-----------------------------------------------------------
>>Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
>>Etiquette: https://curl.haxx.se/mail/etiquette.html
>
>Hi Peng,
>
>You could use the following command to do the same as httpie
>$ curl -v -F file=1.txt localhost:9000
>
>F for https://curl.haxx.se/docs/manpage.html#-F
>v for https://curl.haxx.se/docs/manpage.html#-v
>
>Hope that helps.
>
>Nicolas.

Erratum:
Don't forget to add `@` as a prefix file name
$ curl -v -F file=@1.txt localhost:9000

Nicolas.
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-07-03