Conversion to v2 response object

I’m resurrecting a website that was functioning with the v1 api. I’ve changed the call to the new format, but my code that processes the geojson isn’t working anymore. Did the format change? I’m having a hard time because the chrome debugger isn’t showing the response in hierarchical form anymore. Sorry if this is a dumb question, I’ve just been banging my head against the wall.

let request = new XMLHttpRequest();'POST', "", false);
request.setRequestHeader('Accept', 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'xxx');

request.onreadystatechange = function () {
  if (this.readyState === 4) {
    console.log('Status:', this.status);
    console.log('Headers:', this.getAllResponseHeaders());
    //console.log('Body:', this.responseText);
reqbody = '{"coordinates":[[-114.2531,48.97598],[-114.10499,48.96443]],"elevation":"true"}';

// code to process the response that is failing with NOT FOUND (with Leaflet)
$.getJSON(request.response, function(routeline) {
var routeLayer = L.geoJson(routeline.features[0].geometry, {
onEachFeature: function (feature, layer) {
‘color’ : ‘red’


Hi @mckee80
as far as I know, nothing has changed in the response and it is just the requests that are different between v1 and v2

OK, thanks. Sorry for the bother. Got it to work by removing the jQuery and just using JSON.parse.

Also, the distance and ascent/descent seem to be stored slightly differently in the response:



hmm, not sure if it’s a bug or a feature :grimacing:

In the normal json response it is in the summary object as before.
I think for the geojson it should also be there.
But it seems it will be fixed only in a new version of the API:

1 Like