我试图使用Here Fleet Telematics CalculateRoute.json服务来计算行程成本(收费等)。示例页面使用api_id和api_key进行验证。在我的(Freemium)账户中,我没有看到可以生成这些的方法。
我所做的是复制样本网站的请求,并将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."
}
Update:我希望实现的,是使用POST的http方法。根据 https:/developer.here.comdocumentationfleet-telematicsapi-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参数则是可行的。