1. Bring json directly in curl:
curl -i -X POST -H "'Content-type':'application/json'" -d '{"ATime":"'$atime'","BTime":"'$btime'"}' $url It should be noted that variables in json data should be enclosed in '' 例子:curl -H "Content-type: application/json" -X POST -d '{"phone":"13521389587","password":"test"}' http://domain/apis/users.json
2. Create a json format file, and then reference:
Create a new folder to create a json file: such as:
{ "environment": "Devel", "description": "Machine for test, please do not delete!" }
One level above the folder, use @folder name/json file, such as:
curl -X POST -k -u account:pwd -H "Accept: application/json" -H "Content-Type: application/json" -d @notification_request_json/sendSngleMsg.json http://localhost:8088/notification/sendSngleMsg
All you need to do is use Example:
|
Better than this: (the authentication method is publicized)
curl -i \
-H 'Accept:application/json' \
-H 'Authorization:Basic username:password' \
http://example.com