Tuesday, 23 November 2021

Curl Command for POST with JSON and POST with x-www-form-urlencoded

 

// POST with JSON (For POST with JSON, if outer is single quote, make sure use single quote for all outer, and double quotes for JSON

curl -i \

-H 'Accept:application/json' \

-H 'content-type:application/json;charset=utf-8' \

-X POST -d '{"email":"", "password":"", "unit_test": "1"}' \

http://0.0.0.0.0/api/auth/login \

--trace-ascii /dev/stdout > ~/apiresults.txt


// POST with x-www-form-urlencoded

curl -i \

-H 'Accept:application/json'\

-H 'application/x-www-form-urlencoded' \

-H 'Authorization:Bearer  ' \

-X POST -d 'dummyValue=2002&testValue=123' \

http://0.0.0.0:8080 \

--trace-ascii /dev/stdout > ~/apiresults.txt


No comments:

Post a Comment