【发布时间】:2020-11-17 04:27:27
【问题描述】:
我正在尝试使用 Python 通过 Mapbox API 向数据集添加功能。我正在遵循此指令https://docs.mapbox.com/api/maps/#update-a-dataset,但不断收到此错误:
{'message': 'Provide a single Feature to insert'}
代码如下所示:
rs = []
dictionary = {
"id":1,
"type":"Feature",
"properties":{},
"geometry":{"coordinates":[-83.750246, 42.269375],"type":"Point"}}
url = "https://api.mapbox.com/datasets/v1/voratima/"+dataset+"/features/1?access_token="+access_token
rs.append(grequests.put(url, data=dictionary, hooks = {'response' : do_something}))
grequests.map(rs, exception_handler=exception_handler)
我尝试了以下方法,但都没有效果:
- 使用
requests而不是grequests - 用
json.dumps()包装字典 - 将 put 参数从
data=dictionary更改为json=dictionary - 确保将数据和 URL 的
id设置为1。
完全相同请求的邮递员没有错误。我错过了什么?
【问题讨论】:
标签: python python-requests mapbox mapbox-marker grequests