Select to view content in your preferred language

Origin Destination Cost Matrix example

1197
1
01-30-2018 01:40 PM
AvataDevops
New Contributor

I am trying to call the Origin Destination Cost Matrix service using a REST API. 

I using the following URL and performing a GET call:

https://logistics.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/GPServer/Generat... 

However, I keep getting a HTTP 400 error. Can somebody provide me with an example of how to use this service?

UPDATE:

I actually even tried the URL provided in the documentation (with the right token):

https://logistics.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/GPServer/Generat...{"features":[{"geometry":{"y":51.5254,"x":-0.1891},"attributes":{"Name":"Origin 1","TargetDestinationCount":2,"Cutoff":120,"CurbApproach":0}},{"geometry":{"y":51.5353,"x":-0.1744},"attributes":{"Name":"Origin 2","TargetDestinationCount":3,"Cutoff":90,"CurbApproach":0}}]}&demand_points={"features":[{"geometry":{"y":51.5354,"x":-0.1991},"attributes":{"Name":"Destination 1","CurbApproach":0}},{"geometry":{"y":51.5458,"x":-0.1844},"attributes":{"Name":"Destination 2","CurbApproach":0}}]}&token=<MY-TOKEN>&f=pjson

and it still doesn't work. The documentation seems to be outdated. Perhaps some ArcGis developer can provide some insight here? 

Furthermore, the documentation lists `destinations` as a required parameter but the example has `demand_points`, and switching it still doesn't work!

1 Reply
THKPun
by
New Contributor

I just followed this doc and was able to generate a OD cost matrix. Did you try running your request in Postman instead of your code? Also you might want to try removing the ""{\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}," portion and changing the HTTP method to POST (this might not make any difference)

0 Kudos