Discussion:
Curl on Windows has issues with JSON parameters on command line?
Ayotunde Itayemi
2018-05-11 06:33:14 UTC
Permalink
Hi All,
New to the list. I have been testing various Windows build of curl (7.42,
7.53, 7.59, 7.55 on cygwin) but none seems to work well when the
credentials are supplied in JSON form on the command line (they do work if
you put the JSON credentials in a file and then supply it to curl using the
form @filename).

Sample command that fails with response {"message": "Bad Request"}:

curl -i -X POST -H "Content-Type: application/json" -d
'{"user":"/domain-name/***@domain.com","password":"some-password"}'
https://server-name-fqdn/resource-or-service

The same command succeeds if I store the credentials in JSON format in a
file and then execute:

curl -i -X POST -H "Content-Type: application/json" -d @file
https://server-name-fqdn/resource-or-service


In contrast 7.29.0 (and 7.59) on Linux works fine. For some reason curl on
cygwin won't connect at all and keeps giving "connection timed out." Is it
something Windows is doing to the parameters (thinking parameter expansion)
or some other issue that's actual just peculiar to the Windows version of
curl?


Regards,

Ayotunde
Daniel Stenberg
2018-05-11 08:55:50 UTC
Permalink
Post by Ayotunde Itayemi
New to the list. I have been testing various Windows build of curl (7.42,
7.53, 7.59, 7.55 on cygwin) but none seems to work well when the credentials
are supplied in JSON form on the command line (they do work if you put the
JSON credentials in a file and then supply it to curl using the form
@filename).
Then I'd suggest you add "--trace-ascii log.txt" to both command lines and
compare the logged data and see how they differ in what curl sends.
Post by Ayotunde Itayemi
curl -i -X POST -H "Content-Type: application/json" -d
https://server-name-fqdn/resource-or-service
I strongly advice you to drop the "-X POST" from the command line. That's
almost never the right thing to use, especially not when you use -d already.
Post by Ayotunde Itayemi
In contrast 7.29.0 (and 7.59) on Linux works fine.
I guess the difference is because of different behaviors in the shells. Like
regular windows command prompts don't support single quotes etc.
Post by Ayotunde Itayemi
For some reason curl on cygwin won't connect at all and keeps giving
"connection timed out."
I don't think that's the common experience for curl users on cygwin, since
this is the first time I hear of this. But I'm not sure, maybe we don't have
that many users on cygwin anymore so this issue has just flew under the radar?
--
/ daniel.haxx.se
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette
Loading...