Multiple rounds request

Hi, we’re testing the API v2 using Postman application. Following the API reference we add the tour parameters as JSON array, but the API returns only one route. You can see in the attached image our POST configuration with form-data and the response.

33

Could you help us with this??

Thanks.

In the API/v2 the parameters array should not be JSON encoded.

The locations array may be JSON encoded for backward compatibility, but it’s not required.

Hi could you give a working example how the rounds should be used? I think i tried every markup, but nothing seems to work? I am trying in Postman also… should the parameters be send as key (formfield) parameters?

Thanks!

Here’s an example in Postman:

RouteXL API v2 parameter rounds

Thanks… and how can you tell each round to start and end at a certain location, like in the webversion?

And furthermore, how can you tell from the json which is which route?! It looks like it is just one route.

routxlapi-2|690x345routxlapi-1

The API is very simple, it only creates rounds within one route. Each round will have the same departure, which is the first location. The route will end at the last location.

Hi, I’m having difficulty returning rounds or any other parameter. I’m programming in Javascript and sending the parameters in Json (dataType), as in the image below.

routeXl2

Return is ignoring all the parameters passed.

How to return the route rounds? Change vehicle type …

Could you help me?

Thanks!

Not tested and it all seems fine, but it may be the brackets around the parameters value. Can you give it a try without them? The parameters may now be interpreted as an object within an array. Not sure how that is handled…

It worked! Thanks for your help.

1 Like

Example for Google Scripts:

// Set options
const options = {
‘headers’ : headers,
‘method’ : ‘post’,
‘contentType’: ‘application/x-www-form-urlencoded’,
‘muteHttpExceptions’ : true

};

options.payload = {locations:JSON.stringify(locations),“parameters[rounds]”: rounds};

1 Like

I have the same problem in python. This code gives only one route, in stead of two. I have tried multiple option (the parameters array in a list or in single or double quotes, and combinations) but it kept giving me one route. How can I fix this?

Not an expert in Python, but parameters should not be JSON encoded, it’s expected to be an array. Only the value of locations is expected to be JSON. So we’d try with something like:

parameters[rounds] = 2

Thanks for your reply. Still not working :\ Can you give me an example in this format? :

locations=[{"address":"The Hague, The Netherlands","lat":"52.05429","lng":"4.248618"},{"address":"The Hague, The Netherlands","lat":"52.076892","lng":"4.26975"},{"address":"Uden, The Netherlands","lat":"51.669946","lng":"5.61852"},{"address":"Sint-Oedenrode, The Netherlands","lat":"51.589548","lng":"5.432482"}]

but than with parameters= in stead of locations=?

We’ve installed Python, copied your code and played around with it. We seem to get correct results with this input:

data={'locations':'[{"address":"The Hague, The Netherlands","lat":"52.05429","lng":"4.248618"},{"address":"The Hague, The Netherlands","lat":"52.076892","lng":"4.26975"},{"address":"Uden, The Netherlands","lat":"51.669946","lng":"5.61852"},{"address":"Sint-Oedenrode, The Netherlands","lat":"51.589548","lng":"5.432482"}]', 'parameters[rounds]':2}

Thanks, it works!! Must say I’m impessed by your level of customer care! Two last question about the multiple rounds:

  • I get confusing results when I use different locations as start and finish; not every route has the right start and the right finish. How to fix this?

And my last question:

  • is it possible with multiple routes to have them all start at the same location, but have a different finish for only one route?

Thanks in advance

On your first question, our multiple rounds feature always returns to the first location and ends at the last location of your input.

There is no fix, but a non-optimal workaround is to take the locations of each round separately and create a new route for that with the right start and finish.

On your second question, all rounds always start from the same first location. The final round will end at the final location.

So, if your input has location A, B, C, and so on to location Z, the multiple rounds feature will always create one route with multiple returns to A, ending in Z:

A - - - - A - - - - A - - - - A - - - - Z

=================

Edit: as mentioned in a later post below, the described result is as the website would act. The API will act differently, returning:

A - - - - A - - - - A - - - - A

with Z somewhere in the route as a regular stop.

Thank you for your response, but what you say here:

seems not right. With the following input:

[{"address": "MAGAZIJN", "lat": "52.301153", "lng": "5.239027"}, 
{"address": "12344777", "lat": "52.292895", "lng": "5.240746666666666"}, 
{"address": "12345075", "lat": "52.24288333333333", "lng": "4.810811666666667"}, 
{"address": "12345160", "lat": "51.956581666666665", "lng": "4.963391666666666"}, 
{"address": "12345390", "lat": "52.939935", "lng": "4.735586666666666"}, 
{"address": "12345490", "lat": "52.29616166666667", "lng": "5.160463333333333"}, 
{"address": "12345522", "lat": "52.17655333333333", "lng": "5.6009166666666665"}, 
{"address": "12345530", "lat": "52.661183333333334", "lng": "6.7367799999999995"}, 
{"address": "12345532", "lat": "52.05883333333333", "lng": "4.347488333333334"}, 
{"address": "12345544", "lat": "52.35351333333333", "lng": "4.854746666666666"}, 
{"address": "12345550", "lat": "52.78319", "lng": "6.102668333333333"}, 
{"address": "12345557", "lat": "52.01390166666667", "lng": "4.3495083333333335"}, 
{"address": "12345559", "lat": "52.350053333333335", "lng": "6.671786666666667"}, 
{"address": "12345568", "lat": "52.152816666666666", "lng": "4.7691333333333334"}, 
{"address": "12345571", "lat": "52.34079", "lng": "4.788871666666667"}, 
{"address": "12345578", "lat": "52.351416666666665", "lng": "5.155856666666667"}, 
{"address": "12345591", "lat": "52.19592333333333", "lng": "6.636681666666666"}, 
{"address": "12345592", "lat": "51.92289666666667", "lng": "4.50205"}, 
{"address": "12345595", "lat": "52.28866333333333", "lng": "5.160481666666667"}, 
{"address": "12345596", "lat": "52.15743", "lng": "4.783493333333333"}, 
{"address": "12345601", "lat": "52.677773333333334", "lng": "4.699188333333334"}, 
{"address": "32123", "lat": "52.29749666666667", "lng": "5.2689433333333335"}, 
{"address": "DELFT", "lat": "51.998893", "lng": "4.357264"}]

and

"parameters[rounds]" : "3", "parameters[balance]":"50"

i get the following output, which should go

MAGAZIJN - - - - - MAGAZIJN - - - - MAGAZIJN - - - - - DELFT

which is what I want. But it is as follows:

{'name': 'MAGAZIJN', 'lat': '52.301153', 'lng': '5.239027', 'arrival': 0, 'distance': 0}
{'name': '12345522', 'lat': '52.17655333333333', 'lng': '5.6009166666666665', 'arrival': 29, 'distance': 38.8}
{'name': '12345591', 'lat': '52.19592333333333', 'lng': '6.636681666666666', 'arrival': 90, 'distance': 123.7}
{'name': '12345559', 'lat': '52.350053333333335', 'lng': '6.671786666666667', 'arrival': 112, 'distance': 145.4}
{'name': '12345530', 'lat': '52.661183333333334', 'lng': '6.7367799999999995', 'arrival': 145, 'distance': 190.8}
{'name': '12345550', 'lat': '52.78319', 'lng': '6.102668333333333', 'arrival': 193, 'distance': 253.3}
{'name': 'MAGAZIJN', 'lat': '52.301153', 'lng': '5.239027', 'arrival': 270, 'distance': 355.4}
{'name': '12345390', 'lat': '52.939935', 'lng': '4.735586666666666', 'arrival': 89, 'distance': 472.1}
{'name': '12345601', 'lat': '52.677773333333334', 'lng': '4.699188333333334', 'arrival': 126, 'distance': 509.5}
{'name': '12345571', 'lat': '52.34079', 'lng': '4.788871666666667', 'arrival': 164, 'distance': 556.5}
{'name': '12345544', 'lat': '52.35351333333333', 'lng': '4.854746666666666', 'arrival': 172, 'distance': 562.6}
{'name': '12345490', 'lat': '52.29616166666667', 'lng': '5.160463333333333', 'arrival': 193, 'distance': 588.5}
{'name': '12345595', 'lat': '52.28866333333333', 'lng': '5.160481666666667', 'arrival': 195, 'distance': 589.6}
{'name': '12344777', 'lat': '52.292895', 'lng': '5.240746666666666', 'arrival': 203, 'distance': 596.1}
{'name': 'MAGAZIJN', 'lat': '52.301153', 'lng': '5.239027', 'arrival': 205, 'distance': 597.3}
{'name': '12345578', 'lat': '52.351416666666665', 'lng': '5.155856666666667', 'arrival': 19, 'distance': 617.7}
{'name': '12345075', 'lat': '52.24288333333333', 'lng': '4.810811666666667', 'arrival': 51, 'distance': 653.9}
{'name': '12345596', 'lat': '52.15743', 'lng': '4.783493333333333', 'arrival': 66, 'distance': 666.9}
{'name': '12345568', 'lat': '52.152816666666666', 'lng': '4.7691333333333334', 'arrival': 68, 'distance': 668.7}
{'name': '12345532', 'lat': '52.05883333333333', 'lng': '4.347488333333334', 'arrival': 98, 'distance': 706.8}
{'name': '12345557', 'lat': '52.01390166666667', 'lng': '4.3495083333333335', 'arrival': 106, 'distance': 713.6}
{'name': 'DELFT', 'lat': '51.998893', 'lng': '4.357264', 'arrival': 110, 'distance': 715.9}
{'name': '12345592', 'lat': '51.92289666666667', 'lng': '4.50205', 'arrival': 128, 'distance': 733.4}
{'name': '12345160', 'lat': '51.956581666666665', 'lng': '4.963391666666666', 'arrival': 168, 'distance': 778.8}
{'name': '32123', 'lat': '52.29749666666667', 'lng': '5.2689433333333335', 'arrival': 212, 'distance': 834.3}
{'name': 'MAGAZIJN', 'lat': '52.301153', 'lng': '5.239027', 'arrival': 216, 'distance': 837.2}

How is this possible, and more important: how to fix this?

Thanks in advance

You’re right, what we said is how the website will respond. The API will respond differently as you describe, adding the first location to the end of the array and then fix the last location of the resulting array as finish.

As to a fix, we have none at this moment. Our apologies.

Hi there,

Is is possible to use RouteXL to solve the following delivery route problem?
I have 3 drivers starting from the same location. I have 10 other locations to deliver to. I want the 10 locations to be split among the 3 drivers in the most optimized manner. I don’t wish to input destinations as the drivers can proceed to any destination after completing their deliveries.

Our API can create multiple rounds, but will always arrive at the departure location, as described in this discussion. There is no “open-end” feature.

The non-optimal workaround is to create the route with rounds, use each round as input for each driver, select the farthest location based on coordinates, and make that the last location in the input so it will act as final destination, and create a new route from that.