首页 > 解决方案 > 无法让 Python 补丁请求工作

问题描述

article_url = "https://api.airtable.com/v0/appxxxxxxxxxxx/articles/row_id?api_key=APIKEY"
data = {"fields" : {"contacted" : "hello world"}, "typecast":True}
patch_article_data = requests.patch(article_url, data=data)

我不明白为什么上述方法对补丁请求不起作用。我尝试了很多变体,包括没有类型转换。我得到以下回应。

{u'error': {u'message': u'Invalid request: parameter validation failed. Check your request data.', u'type': u'INVALID_REQUEST_UNKNOWN'}}

标签: pythonpython-requestsairtable

解决方案


I think that the problem is linked with the way you are sending the payload, instead of sending it like a string I would recommend you try sending it as a JSON string by replacing:

patch_article_data = requests.patch(article_url, data=data)

with

patch_article_data = requests.patch(article_url, json=data)

推荐阅读