我试图使用这里的舰队远程信息通信CalculateRoute.json服务,以计算旅行费用(收费等)。示例页面使用api_id和api_key进行身份验证。在我的(免费)帐户中,我看不出有什么方法可以产生这种情况。
我所做的是复制示例站点发出的请求,并将app_id和app_key参数替换为apikey=**key**
。我还删除了jsoncallback参数。我得到了后面的JSON:
{
"faultCode": "s14e781b4-b577-4b58-86bb-359ee5c8a979",
"responseCode": "400",
"message": "The request is missing the app_id and app_code parameters. They must both be passed as query parameters. If you do not have app_id and app_code, please obtain them through your customer representative or at http://developer.here.com/myapps."
}
更新:我希望实现的是使用POST http方法。根据https://developer.here.com/documentation/fleet-telematics/api-reference.html的说法,部分“计算带有额外的舰队远程信息处理功能的路线”应该是可能的。
确切的请求消息是(没有实际的api键):
POST https://fleet.ls.hereapi.com/2/calculateroute.json
Content-Type: application/json
{
"apiKey": "**SNIP**",
"waypoint0": "38.72639,-9.14949",
"waypoint1": "47.54881,7.58782",
"detail": "1",
"maneuverAttributes": "none",
"linkAttributes": "none,sh",
"legAttributes": "none,li",
"currency": "EUR",
"departure": "",
"tollVehicleType": "3",
"trailerType": "2",
"trailersCount": "1",
"vehicleNumberAxles": "3",
"trailerNumberAxles": "2",
"hybrid": "0",
"emissionType": "5",
"fuelType": "diesel",
"height": "4m",
"trailerHeight": "400",
"vehicleWeight": "12000",
"limitedWeight": "40t",
"disabledEquipped": "0",
"minimalPollution": "0",
"hov": "0",
"passengersCount": "1",
"tiresCount": "14",
"commercial": "1",
"heightAbove1stAxle": "1m",
"width": "2.55",
"length": "16.5",
"mode": "fastest;truck;traffic:disabled",
"rollups": "none,country;tollsys",
"alternatives": "1"
}
这将返回以下内容:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Date: Mon, 01 Jun 2020 11:10:09 GMT
Server: nginx-clojure
Content-Length: 74
Connection: Close
{
"error": "Unauthorized",
"error_description": "Token or apiKey is missing."
}
然而,在GET请求中传递与url参数相同的值是有效的。
https://stackoverflow.com/questions/62114238
复制