user1164061
user1164061

Reputation: 4352

curl command syntax for windows

I have the following command which works well on Linux, but not on windows. I am not able to find any doc for curl syntax for windows. I experimented with the quotes .. but still not working. Can anyone help me with this command so that I can use it on Windows ( I have installed curl.exe in c drive)

curl -X POST -H "Content-Type: application/json" -H "X-Cachet-Token: secret" http://somegoodserver/api/v1/incidents -d '{"name":"Test","message":"Test message","status":"1"}'

The error I get is:

"status":400,"title":"Bad Request","detail":"The request cannot be fulfilled due to bad syntax.","meta": {"details":["The name format is invalid.","The status format is invalid.","The message format is invalid."]}}]}

Upvotes: 4

Views: 24510

Answers (1)

James
James

Reputation: 171

Windows requires a ^ at the end of each line, double-quotes instead of single-quotes (except within json brackets), and within the json data, all the double-quotes must be escaped.

Here is an example of a GET and a POST that work on Win10 and WinXP command prompt:

curl -X GET ^
-H "authorization: Basic [your authentication string, if needed]" ^
-H "cache-control: no-cache" ^
-H "content-type: application/json" ^
-H "x-forte-auth-organization-id: org_333251" ^
"https://sandbox.forte.net/api/v3/organizations/org_333251/locations/loc_191620/customers/"


curl -X POST ^
-H "authorization: Basic [your authentication string, if needed]" ^
-H "cache-control: no-cache" ^
-H "content-type: application/json" ^
-H "x-forte-auth-organization-id: org_333251" ^
-d "{ \"action\": \"sale\", \"authorization_amount\": 16.99, \"billing_address\": { \"first_name\": \"Paul\", \"last_name\": \"Hurst\" }, \"card\": { \"card_type\": \"visa\", \"name_on_card\": \"Forte James\", \"account_number\": \"4111111111111111\", \"expire_month\": \"12\", \"expire_year\": \"2020\", \"card_verification_value\": \"123\" } }" ^
"https://sandbox.forte.net/api/v3/organizations/org_333251/locations/loc_191620/transactions" ^

Upvotes: 14

Related Questions