0

我正在使用MailChimp API v3.0,我需要根据 MailChimp API 文档创建一个新的Segment :http: //developer.mailchimp.com/documentation/mailchimp/reference/lists/segments/

它在我的 C# API Wrapper 中不起作用,我正在使用 CURL(文档中建议)进行测试,特别是用于 Windows 的 CURLhttps ://curl.haxx.se/ ...这是我的命令:

curl --request POST --url https://usXX.api.mailchimp.com/3.0/lists/my1i5t1d/segments --header "Authorization: apikey myap1k3y-usXX" --header 'Content-Type: application/json' --data '{"name":"myDynamicSegment"}' --include

响应消息是:

HTTP/1.1 400 Bad Request
Server: nginx
Content-Type: application/problem+json; charset=utf-8
Content-Length: 203
X-Request-Id: 1d001b85-0286-4339-ab37-3cb49c6f28f8
Link: <https://us13.api.mailchimp.com/schema/3.0/ProblemDetailDocument.json>; rel="describedBy"
Date: Thu, 14 Jul 2016 22:06:08 GMT
Connection: close
Set-Cookie: _AVESTA_ENVIRONMENT=prod; path=/

{"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":""}
4

1 回答 1

0

在windows cmd中使用Curl,响应只说:

{"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":""}

但或者我使用了 Git Bash(当你为 Windows 安装 Git 时默认包含https://git-for-windows.github.io/)并且响应不同并且非常有用:

{"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"Must provide either an \"options\" field or a \"static_segment\" field","instance":""}

基于此消息,我在 JSON 中添加了“static_segment”参数,当我调整命令选项 --data 时一切正常:

curl --request POST --url https://usXX.api.mailchimp.com/3.0/lists/my1i5t1d/segments --header "Authorization: apikey myap1k3y-usXX" --header 'Content-Type: application/json' --data '{"name":"myDynamicSegment", "static_segment" : ["test1@domain.com", "test1@domain.com"]}' --include

关于问题/解决方案的评论:

问题解决了!

于 2016-07-18T14:42:46.693 回答