cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Passing spaces to Mailchimp with JSON & Windows

From: Leif W <warp9pnt9_at_gmail.com>
Date: Tue, 17 Dec 2013 05:46:26 -0500

On 2013-12-17 00:50, Owen Watson wrote:
> I'm trying to pass a JSON call to MailChimp via commandline Windows
> and not having much luck.
> I'm using
> curl --insecure -d {JSON call} https://us1.mailchimp.com/list/subscribe
> In the JSON call it works fine if there's no spaces, as you'd expect,
> but as soon as you introduce spaces, even if you replace them by + or
> %20 it falls over.
> Do I have to use something else, or escapes?
Wild guess here, but have you tried double quoting? "{JSON call}". A
more generalized way to test this would be helpful.

However, if the JSON itself contains double quote characters ... hmm. :)

Windows CMD.EXE quoting can be tricky to say the least. A cursory
search yielded this StackOverflow article.

http://stackoverflow.com/questions/355988/how-do-i-deal-with-quote-characters-when-using-cmd-exe

 From what I gather, try different combinations of options for quoting.
You may also need to preface the curl command with CMD.EXE and some
other options and then quote the entire curl command, as well as the
JSON call.

curl --insecure -d "{JSON call}" https://us1.mailchimp.com/list/subscribe

CMD /C "curl --insecure -d "{JSON call}"
https://us1.mailchimp.com/list/subscribe"

CMD /S /C "curl --insecure -d "{JSON call}"
https://us1.mailchimp.com/list/subscribe"

Other than that, I can only think of putting it inside a PHP or Perl
wrapper script and making the call programmatically... passing a URL as
the first argument and a single quoted "{JSON call}" as the second
argument or installing cygwin to use a real shell like bash ... (which I
do from time to time rather than mess with CMD.EXE's limitations and
lack of documentation).

Hope That Helps,

Leif

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-12-17