cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Distance Matrix API Google Maps

Soumya21
Level 6
Hi @KyleStrumberger


I have used Distance Matrix API Google Maps VBO which is available in Digital Exchange to find distance between two postcodes at a time Its giving distance for 1 origin & 25 destinations.
But for some of the postcodes it is unable to find distance because some locations are not displaying in the response from blueprism VBO, but sometimes for the same postcode/location
the output/response is coming with the same VBO and API. If we check manually in google API we are able to get distance for the same postcode.

Unable to rectify what is the reason behind it, as it is very necessary to find distance for multiple locations/postcode, and the whole process depends on the distance fetching through API.

Please help me on this

Thanks,
Soumya


------------------------------
Soumya k RPA Developer
RPA Developer
Qualesce India Private Limited
Bangalore
------------------------------
3 REPLIES 3

PvD_SE
Level 12
Hi Soumya,

Assumptions:
  • Your API is called with a list of postcodes that you need for the calculation.
  • Before calling the API, you populate the IN postcode list with your collection of postcodes that you have in BP.
  • In the API answer, there should be a similar list of postcodes, but now with the distance between each set of postcodes.
  • After the API call, the OUT list is copied to a BP collection.
By running the API call in debug, you should get a pretty good idea of what is missing.

Some questions: 
  1. Is you postcode collection complete?
  2. Is the IN list on the API call complete?
  3. Is the OUT list from the API complete?
  4. Is the BP collection containing the copied OUT list complete?
If step 1 is no: fix the process
If step 2 is no: fix the process
If step 3 is no: check the API code
If step 4 is no: fix the process

------------------------------
Happy coding!
---------------
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

Hi @Paul JHM van Doorn

the issue might be in 2 or 3. it might be on the IN list on the API call or the Out list from the API call but unable to identify issue from the code as I am sending the postcode collections(origin&destination)

Automatically in the response sometimes origin is not appearing and sometimes some of destinations are not appearing​.


this is the code in the VBO for creating parameter for multiple addresses

var parameters = new Dictionary<string, string>();

 

parameters.Add("origins", JoinAndUrlEncodeLocations(Origins
                                                .Rows
                                                .OfType<DataRow>()
                                                .Select(row => row[0].ToString())));

 

parameters.Add("destinations", JoinAndUrlEncodeLocations(Destinations
                                                    .Rows
                                                    .OfType<DataRow>()
                                                    .Select(row => row[0].ToString())));
if(Mode != string.Empty){parameters.Add("mode", Mode);};
if(Language != string.Empty){parameters.Add("language", Language);};
if(Region != string.Empty){parameters.Add("region", Region);};
if(Avoid != string.Empty){parameters.Add("avoid", Avoid);};
if(Units != string.Empty){parameters.Add("units", Units);};
if(TrafficModel != string.Empty){parameters.Add("traffic_model", TrafficModel);};
if(TransitMode != string.Empty){parameters.Add("transit_mode", TransitMode);};
if(TransitRoutingPreference!= string.Empty){parameters.Add("transit_routing_preference", TransitRoutingPreference);};
if(ArrivalTime != string.Empty){parameters.Add("arrival_time", ArrivalTime);};
if(DepartureTime != string.Empty){parameters.Add("departure_time", DepartureTime);}

 

Parameters = string.Join("&", parameters.Select(x => String.Format("{0}={1}",x.Key, x.Value)));



Thanks,
Soumya​

------------------------------
Soumya k RPA Developer
RPA Developer
Qualesce India Private Limited
Bangalore
------------------------------

Hi Soumya,

Ok, choice 2 or 3 narrows it down for us. Next step would be debugging the code that calls the API. Unfortunately, BP does not (yet?) allow debug of code stages...

From your answer I reckon you are a programmer (as am I, albeit other languages) in VB or C# (...I can never tell the difference:-). My suggestion would be to create a program that calls the API in the same manner as done from BP by copying the code you already have. That program would be debuggable (is that even a word?) and allow you to get the parameters sorted out. Once you got that working, you can adjust the BP code stage accordingly.

------------------------------
Happy coding!
---------------
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)