curl / Mailing Lists / curl-users / Single Mail

curl-users

Windows cURL JSON POST sysntax

From: Vince Hurst <vincehurst_at_hotmail.com>
Date: Thu, 29 Dec 2016 22:34:04 +0000

I've got a problem with possibly forming the correct syntax to send a JSON POST. This is only the case using the Windows versions of cURL. When I use Linux, there's no problem.

I'm using the following:

curl --trace log.txt -H "Content-Type: application/json" -d '{"recipients": ["1234567890"],"message": "Hello World"}' http://172.21.20.120/api/sms/outbox?token=184D57B32AB68DC7784A32C9CDC456C

I get the following error:

----------------------------------------------------------------------------------------------

curl: (3) [globbing] bad range in column 2
curl: (3) [globbing] unmatched close brace/bracket in column 11
HTTP/1.1 400 Bad Request
Content-type: application/json
Transfer-Encoding: chunked
Date: Thu, 29 Dec 2016 21:12:35 GMT
Server: rcell

{
   "code" : 400,
   "error" : "json parser: * Line 1, Column 1\n Syntax error: value, object or
array expected.\n* Line 1, Column 1\n A valid JSON document must be either an a
rray or an object value.\n",
   "status" : "fail"
}

----------------------------------------------------------------------------------------------

Looking at the log file, the only JSON data is this: '{recipients:

By removing all spaces within the JSON data, the log files show the full JSON data bein passed: '{recipients:[1234567890],message:HelloWorld}'

Either way, all the double quotes are removed, and the device still complains that the syntax is bad.

----------------------------------------------------------------------------------------------

{
   "code" : 400,
   "error" : "json parser: * Line 1, Column 1\n Syntax error: value, object or
array expected.\n* Line 1, Column 1\n A valid JSON document must be either an a
rray or an object value.\n",
   "status" : "fail"
}

----------------------------------------------------------------------------------------------

Is this a bug, or is there a better way to form my syntax to work with the Windows version of cURL?

Thanks,

-Vince

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-users
FAQ: https://curl.haxx.se/docs/faq.html
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-12-29