curl / Mailing Lists / curl-users / Single Mail

curl-users

Re: Windows cURL JSON POST sysntax

From: Jeremy Nicoll <jn.ml.crlu.36_at_letterboxes.org>
Date: Thu, 29 Dec 2016 23:44:26 +0000

On Thu, 29 Dec 2016, at 23:20, Ray Satiro via curl-users wrote:

> In the Windows command shell you have to use outer double quotes for the
> string and escape any inner double quotes, for example
>
> curl -H "Content-Type: application/json" -d "{\"recipients\":
> [\"1234567890\"],\"message\": \"Hello World\"}" http://foo

Backslash isn't (or at least didn't use to be) an escape character for
the cmd.exe
command shell. Unless... is it one of those things that one has to
turn on or off
when starting the shell itself (see 'help cmd' for that)?

Or are you using eg PowerShell, which I know nothing about?

> It may be easier for you to put it in a file, for example
>
> curl -H "Content-Type: application/json" --data-binary @filename
> http://foo

That strikes me as a better way to do something like this, even if (if
the curl command
is being issued by a script) you have to create the file from within the
script. At least
that way you can be sure that curl actually sees the same file contents
as are actually
in the file, without shell processing getting in the way.

-- 
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.html
Received on 2016-12-30