I am attempting to use the default javascript (or PHP) code example from here - https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/geojson/post - regarding getting a geoJSON route for driving-car, and although using my api key works when I hit the “call action” button and the “API response” on the example page returns both the map route and the GeoJSON code … clicking the download button returns a file that just contains the words [object][object] … and using the exact same code in my own project throws an HTTP 500 error with the following response;
{“error”:{“message”:“Content type ‘text/plain;charset=UTF-8’ not supported”},“info”:{“engine”:{“version”:“5.0.1”,“build_date”:“2019-05-29T14:22:56Z”},“timestamp”:1568626847241}}
just for info the default code used is the following;
let request = new XMLHttpRequest();
request.open('POST', "https://api.openrouteservice.org/v2/directions/driving-car/geojson");
request.setRequestHeader('Accept', 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8');
request.setRequestHeader('Authorization', 'my-api-key-removed');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
const body = '{"coordinates":[[8.681495,49.41461],[8.686507,49.41943],[8.687872,49.420318]],"instructions":"false"}';
request.send(body);