始终使用 curl 为用户订阅 MailChimp 列表 returns "We encountered an unspecified JSON parsing error"

Subscribing a user to a MailChimp list using curl always returns "We encountered an unspecified JSON parsing error"

我有一个创建批处理文件的应用程序,然后调用该文件

我需要向 MailChimp 列表添加订阅者

curl.exe -v --request POST --url "https://us11.api.mailchimp.com/3.0/lists/list_id/members" --user "anystring:api_key" --header "content-type: application/json" --data "{"email_address":"urist.mcvankab+3@freddiesjokes.com", "status":"subscribed"}" --include

我已经按照建议更新了请求,但仍然出错。是的,双引号似乎是问题所在。

{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"JSON Parse Error","status":400,"detail":"We encountered an unspecified JSON parsing error.","instance":""}

Note: Unnecessary use of -X or --request, POST is already inferred.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 92.123.199.167...
* Connected to us11.api.mailchimp.com (92.123.199.167) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:\DevPB\Epos\ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [104 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [2662 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=Georgia; L=Atlanta; O=The Rocket Science Group, LLC; OU=IT; CN=*.api.mailchimp.com
*  start date: May  3 00:00:00 2016 GMT
*  expire date: May  3 23:59:59 2017 GMT
*  subjectAltName: host "us11.api.mailchimp.com" matched cert's "*.api.mailchimp.com"
*  issuer: C=US; O=GeoTrust Inc.; CN=GeoTrust SSL CA - G3
*  SSL certificate verify ok.
* Server auth using Basic with user 'anystring'
} [5 bytes data]
> POST /3.0/lists/XXXXXXXX/members HTTP/1.1
> Host: us11.api.mailchimp.com
> Authorization: Basic XXXXXXXXXXXXXXXXXXXXX
> User-Agent: curl/7.50.1
> Accept: */*
> content-type: application/json
> Content-Length: 69
>
} [69 bytes data]
* upload completely sent off: 69 out of 69 bytes
{ [5 bytes data]
< HTTP/1.1 400 Bad Request
< Server: openresty
< Content-Type: application/problem+json; charset=utf-8
< Content-Length: 203
< X-Request-Id: 145d8a92-f4c5-4a83-8e1f-f72cf7850c45
< Link: <https://us11.api.mailchimp.com/schema/3.0/ProblemDetailDocument.json>; rel="describedBy"
< Date: Wed, 18 Jan 2017 13:42:59 GMT
< Connection: close
< Set-Cookie: _AVESTA_ENVIRONMENT=prod; path=/
<
{ [203 bytes data]
100   272  100   203  100    69    419    142 --:--:-- --:--:-- --:--:--   419
* Closing connection 0
} [5 bytes data]
* TLSv1.2 (OUT), TLS alert, Client hello (1):
} [2 bytes data]

C:\DevPB\Epos>

这可能是由于 windows 终端不支持单引号引起的。用双引号替换您的数据。例如

--data "{\"email_address\"...}"

也可以尝试 运行 您的命令,将 -v 切换到调试输出。如果它不起作用,请使用输出更新您的问题。