1

I'm trying to use the Here Fleet Telematics CalculateRoute.json service, to calculate trip costs (toll, etc). The sample page uses api_id and api_key for authentication. In my (Freemium) account, I don't see a way where I can generate that.

What I did is copy the request the sample site makes, and replace the app_id and app_key parameters with apikey=**key**. I also removed the jsoncallback parameter. I get the back following 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: What I hope to achieve, is use the POST http method. According to https://developer.here.com/documentation/fleet-telematics/api-reference.html, section "Calculates a route with additional fleet telematics features", that should be possible.

The exact request message is (without actual api key):

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"
}

This returns the following:

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."
}

Whereas, passing all the same values as url arguments in a GET request works.

1 Answer 1

1

You need to use the following endpoint:

https://fleet.ls.hereapi.com/2/calculateroute.json?apiKey={YOUR_API_KEY}&...

See Send a Request and Calculate Toll Cost documentation pages.

Sign up to request clarification or add additional context in comments.

4 Comments

For GET requests, it now works, but I really hoped to be able to use POST requests. With the endpoint you gave, I now get the following JSON: json { "error": "Unauthorized", "error_description": "Token or apiKey is missing." } while apiKey is the first property in the json.
Can you edit your question with more details about what you're trying to achieve, and based on which documentation page? Please add the request you're trying as well as the query parameters.
@mterwoord The above request works with GET or POST methods. Might not be particularly obvious, but the parameters apiKey, mode, waypointN and many others are expected as query parameters, as they are listed under "Query Parameters" in the API Reference. The request body is for sending trace files.
That explains a lot then. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.