发布包含DICS列表的请求数据
我试图调用想要一个值列表的API。 我构建一个看起来与此相似的dict:
dataset = {
'name': 'somename',
'note': 'somenote',
'extras': [{'first': 'entry'}]
}
我将其包括在我的帖子中:
r = requests.post("URL_ENDPOINT", data=dataset, headers=headers)
检查实际数据集
字典正确显示了dicts的列表。
{'name': 'somename', 'note': 'somenote', 'extras': [{'spatial': 'test'}]}
但是检查请求对象,r.text
:
... "extras": "first", "type": "dataset"}}, ...
看来dicts的列表正在以某种方式弹出?
I'm trying to call an API that wants a list of dicts for one value.
I build a dict that looks similar to this:
dataset = {
'name': 'somename',
'note': 'somenote',
'extras': [{'first': 'entry'}]
}
I'm including this in my POST:
r = requests.post("URL_ENDPOINT", data=dataset, headers=headers)
Checking the actual dataset
dictionary shows the list of dicts correctly.
{'name': 'somename', 'note': 'somenote', 'extras': [{'spatial': 'test'}]}
But checking the requests object, r.text
:
... "extras": "first", "type": "dataset"}}, ...
It looks like the list of dicts is being munged in some fashion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试注入
JSON
参数而不是数据
Try to inject
json
parameter instead ofdata
我远不聪明 - API希望dict使用“键”和“ value”:
我确实尝试了一个JSON软件包,看起来它也可以正常工作。非常感谢!
I’m less than smart - the API wanted the dict to use “key”: and “value”:
I did try a JSOn package and it looks like it would work also. Thank you very much!