Python 2.7 发布到asana api以向任务添加追随者时,无法识别请求字段“追随者”

Python 2.7 发布到asana api以向任务添加追随者时,无法识别请求字段“追随者”,python-2.7,curl,python-requests,asana-api,Python 2.7,Curl,Python Requests,Asana Api,我第一次使用AsanaAPI。 我所做的是使用python请求库将数据发布到asana api 运行此curl命令时,效果良好 curl --request POST -H "Authorization: Bearer 12345678" https://app.asana.com/api/1.0/tasks/1234/addFollowers --data-urlencode "followers=191563290920498" 这是预期的工作,但当使用此代码时,我得到了错误 url =

我第一次使用AsanaAPI。 我所做的是使用python请求库将数据发布到asana api

运行此curl命令时,效果良好

curl --request  POST -H "Authorization: Bearer 12345678" https://app.asana.com/api/1.0/tasks/1234/addFollowers --data-urlencode "followers=191563290920498"
这是预期的工作,但当使用此代码时,我得到了错误

url = "https://app.asana.com/api/1.0/tasks/1234/addFollowers"
headers = {"Authorization":"Bearer 12345678"}
data = {"followers":[191563290920498]}
d =json.dumps(data)
response = requests.post(url,data = d ,headers= headers,verify = False)
错误是

{u'errors': [{u'message': u'Unrecognized request field `followers`. The only allowed keys at the top level are: data, options, auth. Is it possible you did not wrap object properties in a `data` object?', u'help': u'For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors'}]}
服务器响应是400,所以我传递数据的方式肯定有问题。 我不知道我做错了什么。感谢您的帮助:)

我也尝试过这种实现:-

response = requests.post(url,params=d ,headers= headers,verify=False)
在这种情况下,错误消息是

{u'errors': [{u'message': u'Could not parse request data, invalid JSON', u'help': u'For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors'}]}
响应代码是


上面的代码是否正是您所使用的?该错误提到“Followers”,但您传递的是“Followers”。除此之外,您是否尝试过直接传递
数据
?例如,
response=requests.post(url,data=data,headers=headers,verify=False)
@etemple1这是一个打字错误,现在已更正。回答你的第二个问题是的,我用data=data试过了,在这种情况下,错误信息是这样的。{u'errors':[{u'message':u'followers:Missing input',u'help':u'有关API状态代码以及如何处理它们的详细信息,请阅读有关错误的文档:'}]}AsapaAPI是restful的,所以我必须以json格式传递数据。我不知道现在发生了什么,但data=data正在工作。:)