The blog of Adwi Arifin

Wednesday, October 18, 2017

Sintaks cURL



Berikut contoh-contoh penggunaan cURL secara sederhana yang sering digunakan

1. With fields
curl --data "param1=value1&param2=value2" https://example.com/resource.cgi
2. Multipart
curl --form "fileupload=@my-file.txt" https://example.com/resource.cgi
3. Multipart with file
curl --form "fileupload=@my-file.txt;filename=desired-filename.txt" --form param1=value1 --form param2=value2 https://example.com/resource.cgi
4. 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

Untuk file yang cukup besar, coba gunakan sintaks berikut untuk menampilkan proses upload:
curl --tr-encoding -X POST -v -# -o output -T filename.dat \
  http://example.com/resource.cgi
Catatan: -o output perlu dituliskan dalam parameter, kalau tidak, proses upload tidak akan tampil.


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

0 comments:

Post a Comment

Visit our Site

Total Pageviews