Saturday 8 December 2018

Curl

Simple Curl commands
GET

# curl -i \
 -H 'Content-Type: application/json' \
 -X GET 'http://127.0.0.1/~jxiang/response_GET.php'

POST

# curl -i \

        -H "Accept: application/json" \

        -H "Content-Type: application/json" \

        -X POST -d'{"token":"xxxxx","test_data":[{"id":xxxxx}]}' \

         "http://127.0.0.1/~jxiang/response_POST.php" \
 

Trace Curl results with --trace-ascii /dev/stdout and output in a file

# curl -i \

        -H "Accept: application/json" \

        -H "Content-Type: application/json" \

        -X PUT -d'{"version":4}' \

         "http://127.0.0.1/jxiang/test.php" \

         --trace-ascii /dev/stdout > outputfile.php

 

Curl GET with HTTP simple authentication

# curl -i \

        -H "Accept: application/json" \

        -H "Content-Type: application/json" \

        --user xxx:xxxx \

       "https://127.0.0.1/jxiang/test2"



No comments:

Post a Comment