将mailchimp curl请求转换为python请求

2024-06-10 21:15:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我能够成功地运行curl,但不能处理mailchimp的python请求API。它给出错误like urllib2.HTTPError: HTTP Error 401: Unauthorized

卷曲

curl --request POST \
--url 'https://us9.api.mailchimp.com/3.0/lists' \
--user 'anystring:6a983664930fc8ba1eecdsdf334344f40-us9' \
--header 'content-type: application/json' \
--data '{"name":"My test","contact":{"company":"Cool","address1":"Awesome place","city":"Lanka","state":"MH","zip":"43472","country":"IN","phone":""},"permission_reminder":"You'\''re receiving this email because you signed up.","campaign_defaults":{"from_name":"VD","from_email":"hey@sdfsdf.com","subject":"","language":"en"},"email_type_option":true}' \
--include

Python请求:

^{pr2}$

我提到过Converting cURL to Python Requests,但没有成功。在


Tags: namefromcomapihttpemailtype错误
1条回答
网友
1楼 · 发布于 2024-06-10 21:15:01

我已经解决了。这是数据中心的URL问题。我在用us9.api。。。而不是我们6。api.mailchimp.com/3.0/列出,因为我的帐户是在us6下创建的。所以,我需要使用数据中心,在那里我的帐户注册到我的URL请求。在

相关问题 更多 >