Hi,
I’m just starting to use the api, and I’m trying to get the distances and durations between multiple sources and a single destination.
I am first testing through the api playground.
I have a list of (4) locations.
I want the first location to be the destination, the other ones are the sources (so all is fine).
When using “[0]” in the destination field, I get the following error message:
“Could not write JSON: (was java.lang.ArrayIndexOutOfBoundsException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.ArrayIndexOutOfBoundsException) (through reference chain: heigit.ors.api.responses.matrix.JSONMatrixResponseObjects.JSONMatrixResponse["matrix"])”
Am I interpreting the instructions incorrectly?
Wouter
This is my full call (using the javascript)
var request = new XMLHttpRequest(); request.open('POST', "https://api.openrouteservice.org/v2/matrix/driving-car?"); request.setRequestHeader('Accept', 'application/json; charset=utf-8'); request.onreadystatechange = function () { if (this.readyState === 4) { console.log('Status:', this.status); console.log('Headers:', this.getAllResponseHeaders()); console.log('Body:', this.responseText); } }; var body = '{"locations":[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]],"destinations":[0],"metrics":["duration","distance"],"units":"km"}'; request.send(body);