Access to route and analysis API

506
0
12-09-2020 12:26 AM
JasonWestley
New Contributor

Hi, 
I’d like to get the drive time between two points in the UK using the REST API, and I'm working in Postman at the moment. I believe this can be done in two ways, but I’m unable to get either of them to work, for different reasons. I have successfully generated a token in an earlier piece of work. This token works fine for other calls, such as GetTravelMode, the portal/self call, and a call to a feature layer using a call in the form https://services1.arcgis.com/.../arcgis/rest/services/.../FeatureServer/extractChanges.
 
So, onto the calls I’ve tried:
 
The first is by using the https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve  endpoint.
My call is:
 
https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?f=json&token=##...; -117.184,34.0546
 
But I get this response in Postman:
{
    "error": {
        "code": 403,
        "subcode": 2,
        "message": "User does not have permissions to access 'world/route.mapserver'.",
        "details": []
    }
}
 
The second method I’ve tried is using the connectOriginsToDestinations endpoint http://<analysis url>/connectOriginsToDestinations/submitJob
With this, I’m not so clear on the URL I need. I’ve tried this URL in a POST call:
https://analysis.arcgis.com/arcgis/rest/services/connectOriginsToDestinations/submitJob
 
I’ve supplied parameters of:
f=json
token=our token,
originsLayer = a layer definition object {"layerDefinition": {"geometryType": "esriGeometryPoint","fields": [{"name": "Id","type": "esriFieldTypeOID","alias": "Id"},{"name": "Name","type": "esriFieldTypeString","alias": "Name"}]},"featureSet": {"geometryType": "esriGeometryPoint","spatialReference": {"wkid": 4326},"features": [{"geometry": {"x": -100.65,"y": 33.69},"attributes": {"Id": 67,"Name": "Feature 2"}}]}},
destinationsLayer = a layer definition object {"layerDefinition": {"geometryType": "esriGeometryPoint","fields": [{"name": "Id","type": "esriFieldTypeOID","alias": "Id"},{"name": "Name","type": "esriFieldTypeString","alias": "Name"}]},"featureSet": {"geometryType": "esriGeometryPoint","spatialReference": {"wkid": 4326},"features": [{"geometry": {"x": -104.44,"y": 34.83},"attributes": {"Id": 43,"Name": "Feature 1"}}]}},
measurementType = a travel mode object that I successfully obtained from the https://route.arcgis.com/arcgis/rest/services/World/Utilities/GPServer/GetTravelModes/execute endpoint.
 
For this call I get back this error:
{"error":{"code":498,"message":"Invalid token.","details":[]}}
 
However I know the token is OK, as I can refresh it and use it for other calls without any error.
 
So I’m after advice on which of these call is the most sensible to use to get simple drive time information between two points (I don’t even need the route – just the time), and how to make the call work. I know very little about ArcGIS itself, having been asked to connect another one of our internal systems to the API in order to get this information. I have asked our administrator to check that I have the correct permissions, but he's checked everything he can think of without any success.

Any advice would be much appreciated.
 
Thanks,
 
Jason.

0 Kudos
0 Replies