23 mars 2016

[UNIX/LINUX] exemples requêtes curl

Source : http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

With fields:

curl --data "param1=value1&param2=value2" https://example.com/resource.cgi
Multipart:
curl --form "fileupload=@my-file.txt" https://example.com/resource.cgi
Multipart with fields and a filename:
curl --form "fileupload=@my-file.txt;filename=desired-filename.txt" --form param1=value1 --form param2=value2 https://example.com/resource.cgi
Without data:
curl --data '' https://example.com/resource.cgi

curl -X POST https://example.com/resource.cgi

curl --request POST https://example.com/resource.cgi
For more information see the cURL manual. The cURL tutorial on emulating a web browser is helpful.

With libcurl, use the curl_formadd() function to build your form before submitting it in the usual way. See the libcurl documentation for more information.

For large files, consider adding parameters to show upload progress:
curl --tr-encoding -X POST -v -# -o output -T filename.dat \
  http://example.com/resource.cgi
The -o output is required, otherwise no progress bar will appear.

Aucun commentaire:

Enregistrer un commentaire

Vim Survival Kit

 https://learn.acloud.guru/handson/f7fcd48d-5126-48de-b7c5-7c3776bd48ce