Select to view content in your preferred language

Use custom ArcGIS Server route service in leaflet app

109
0
3 weeks ago
Labels (1)
LaboratorioGeomatica2
New Contributor

Hi all,

I am developing an application in leaflet and I am following the example "Find a route and directions" at the Esri Leaflet page. 

In ArcGIS online I created the API key and initialized in my script the value of accessToken variable.

const accessToken = "AAPTxy8BH1VEsoebNVZXo8HurM........";

...

function updateRoute() {
// Create the arcgis-rest-js authentication object to use later.
const authentication = arcgisRest.ApiKeyManager.fromKey(accessToken);

// make the API request
arcgisRest
.solveRoute({
stops: [startCoords, endCoords],
endpoint: "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve",
authentication
})

and the script runs correctly.

my goal is to not use Esri's routing service, but the one on my ArcGIS Server. Obviously ArcGIS Server service doesn't work with the ArcGIS Online token, so I acquired the ArcGIS Server token but don't know how to use it in the code.

When the solveRoute function is executed, the code goes into error: ArcGISAuthError: 498: Invalid Token

How can I integrate my routing service within the application code?

Thank you for your help.

Best regards

Massimo

0 Kudos
0 Replies