VRP Python请求

我是这里的新手。我试图使用VRP例程来解决使用Python 3.7的your website上的示例问题,但是我遇到了一些问题。

我遵循了所有说明here,在其中说明了如何针对VR问题获取承载令牌(使用Python),并且看来工作正常。在下面的代码中,responseblog page的最终输出,它包含生成的承载令牌。如您所见,我为变量headers(对于VRP例程)尝试了不同的方法

...
response = requests.post(url,data=body,headers=headers)


access_token = response.json()['access_token']

headers = {'Content-Type' : 'application/json',#           'Authorization' : 'Bearer"'+response.json()['access_token']+'"'
#           'Authorization' : response.json()['access_token']
#           'Authorization' : 'Bearer<'+response.json()['access_token']+'>'
#           'Authorization' : 'Bearer'+response.json()['access_token']
           'Authorization' : 'Bearer="'+access_token+'"'
#           'Authorization' : 'bearer="'+access_token+'"'
          }

URL = "https://vrp.api.here.com/v1/problems"

body = {
        "id": "myProblem","plan": {
            "jobs": [
              {
                "id": "myJob","places": {
                  "delivery": {
                    "location": {"lat": 52.46642,"lng": 13.28124},"times": [["2020-08-13T10:00:00.000Z","2020-08-13T12:00:00.000Z"]],"duration": 180
                  }
                },"demand": [1]
              }
            ]
          },"fleet": {
            "types": [
              {
                "id": "myVehicle","profile": "car","costs": {
                  "distance": 0.0002,"time": 0.004806,"fixed": 22
                },"shifts": [{
                  "start": {
                    "time": "2020-08-13T09:00:00Z","location": {"lat": 52.52568,"lng": 13.45345}
                  },"end": {
                    "time": "2020-08-13T18:00:00Z","lng": 13.45345}
                  }
                }],"capacity": [10],"amount": 1
              }
            ],"profiles": [{
              "name": "normal_car","type": "car"
             }]
          }
        }
    
# sending get request and saving the response as response object 
r = requests.post(URL,headers=headers)
print(r.text)

我得到的是

{"error":"Unauthorized","error_description":"Bearer token invalid. Bearer missing or bearer value missing."}

我看到了关于StackOverflow herehere的相关问题,但是它们都没有完整的答案。 body已从此处的网站复制。我认为该错误来自VRP的headers。还是我在担心?我的应用程序确实需要Python代码

在此先感谢您的帮助。

相关文章

功能概要:(目前已实现功能)公共展示部分:1.网站首页展示...
大体上把Python中的数据类型分为如下几类: Number(数字) ...
开发之前第一步,就是构造整个的项目结构。这就好比作一幅画...
源码编译方式安装Apache首先下载Apache源码压缩包,地址为ht...
前面说完了此项目的创建及数据模型设计的过程。如果未看过,...
python中常用的写爬虫的库有urllib2、requests,对于大多数比...