Owen Watson | 15 Jun 2012 06:37
Picon

Calling MailChimp with json in post

Having a bit of trouble talking to MailChimp with its json option.

C:\Windows\system32>curl.exe  --data-urlencode
{"apikey":"XXXX","id":"YYYY","email_address":"owen <at> junk.com"}
http://us2.api.mailchimp.com/1.3/?method=listSubscribe
gets this back:
Warning: Couldn't read data from file
Warning: "{apikey:XXXX,id:YYYY,email_addr
Warning: ess:owen <at> junk.com}", this makes an empty POST.
{"error":"You must specify a apikey value for the listSubscribe
method","code":-90}

I assume that the last line comes back from MailChimp, but I don't
think it's being sent the right data.
The --data-urlencode man explanation is a little unclear; it talks
about no  <at>  being in the url, but I though that was the whole point of
urlencoding?
All help gratefully received.
curl 7.26.0

--

-- 
Owen Watson
-------------------------------------------------------------------
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

Owen Watson | 16 Jun 2012 04:01
Picon

Re: Calling MailChimp with json in post

Sorted it out: once I escaped the quote marks as \" all was well. Is
there something in the curl docs with a big warning for Windows users
about quote marks? Didn't notice it; if there isn't, may be worth it.
-------------------------------------------------------------------
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

Kamil Dudka | 16 Jun 2012 09:27
Picon
Favicon
Gravatar

Re: Calling MailChimp with json in post

On Saturday, June 16, 2012 14:01:47 Owen Watson wrote:
> Sorted it out: once I escaped the quote marks as \" all was well. Is
> there something in the curl docs with a big warning for Windows users
> about quote marks?

I suspect it was your shell who ate them, not curl.  But I am not a Windows 
user myself to tell for sure.  Try to precede the whole command with 'echo' 
and see whether the quote marks appear in the echoed string.

Kamil
-------------------------------------------------------------------
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


Gmane