Confusion on how to use "sources" and "destinations"


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?


This is my full call (using the javascript)

var request = new XMLHttpRequest();'POST', "");

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

1 Like

Hi @wodraeve - thank you for finding this issue, it seems like it is a bug. If you actually use driving-hgv as a profile it will work. We will get behind it and message you once it is fixed! Cheers, Tim

Thanks. When I change the profile to driving-hgv, I only get a single response, only the destination itself, not the other locations. Thanks for looking into it.

@wodraeve this will be fixed by the end of the week ( ) , stay tuned - cheers, Tim