curl-users
Re: Windows cURL JSON POST sysntax
Date: Thu, 29 Dec 2016 22:47:37 +0000
On Thu, 29 Dec 2016, at 22:34, Vince Hurst wrote:
> 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
Is this a command exactly as you typed it in a command window, or has it
been issued from
some scripting language which may have added an extra layer of
complexity in its handling
of embedded single & double quotes?
If it's a problem in a command window, are you aware that the caret
symbol: ^ is what windows
uses as an escape character on command lines? I think you might need to
precede some of the
double-quotes with ^ so that they are treated as literals. For example,
you might need
... -d '{^"recipients^": [^"1234567890^"],^"message^": ^"Hello
World^"}'
I've had to use ^ in the past in commands where "<" and ">" needed to
be present and not get
treated as redirection operators.
-- Jeremy Nicoll - my opinions are my own. ------------------------------------------------------------------- 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.htmlReceived on 2016-12-29