I am trying to follow Esri documentation and create an "item" in ArcGIS Online consisting of the ArcGIS World Routing Service, so that I can have some control over the service's use: I have stored credentials for a particular user and limited the credits the service can use. This is all described in this documentation written by @ScottSandusky ; unfortunately it is from 11 years ago:
I want to use my AGOL "item" (the world routing service) in a third-party web app, used by staff in my organization for routing. So I need to figure out the URL I should use in this application to connect to my AGOL "item."
My question is: The above documentation says to use the URL labeled as "ArcGIS Web API REST Connection," which is shown on the item's Item Details page. The problem is that since this documentation is from 11 years ago, much has changed in AGOL, and I do not see anything like that now. There is the item URL at the bottom of the Item Details page, but it is simply the standard, generic URL for the world routing service (see screenshot below). I am afraid that if I use this URL in my app, the app will use the routing service from the source, and it will have zero connection to my AGOL "item" and therefore not pay attention to the credit usage limit I have set for the routing service. Do you know what I mean? Like, I would think that my AGOL item for the routing service would have a unique URL that would tell the app to use my specific connection to the routing service (like a URL that includes a string of random letters and numbers, like all other items I create in AGOL), but this appears to not be the case.
In other words, isn't it pointless to create this Routing Service item in AGOL if my third-party app will have to just use the standard routing service URL (https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World), which presumably leads the app to NOT connect to my AGOL item where I have configured credit limits?
Scott Sandusky, would you be able to provide any insight?
thank you for reading!!
My AGOL item's URL:
Hmm, I just discovered something:
When I hit the "copy" button by my content item's URL on the Item Details page, I get this URL, the standard URL for the world routing service, as I said in my original post:
https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World
However, when I right-click on the "View" button by the URL and then choose "copy link address," the URL I obtain includes a token. So... is THIS the URL I am supposed to use in my third-party app? I don't know anything about tokens; can this one token be used by the app forever, as opposed to needing a new token each time someone uses the app?
I am not sure how you created the item. This is what I tried in my ArcGIS Online organization and it works as expected
1. Create a new item of type "URL" (this includes ArcGIS Server web service)
2. Specify the URL to ArcGIS Routing service (https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World) and make sure the toggle to store credentials with service item is turned on
3. Specify the credentials (ArcGIS Online named user credentials for which you have enabled credit budgeting) and then additional details such as item name and tags.
4. Once the item is created, the URL property towards the bottom right of the item details page should list a URL that should have a pattern such as
https://utility.arcgis.com/usrsvcs/servers/<itemID>/rest/services/World/Route/NAServer/Route_World
This is the URL that you should use in your apps to access the routing service in a controlled manner.
Additionally from the item details page, Under settings >> Limit usage, you configure additional constraints such as a rate limit and HTTP referrers that are required to access the routing service through this URL.
In the below example, I am setting a rate limiting as well as the HTTP referrer for the app that will use this service endpoint.
Additional documentation about what I described is at
Limit usage of secured services
Hope this helps
Thank you so much for your reply!
I did actually create my item using the exact same steps you describe.
When I reopened my routing item in AGOL just now, I saw that its URL was different than earlier today. the URL has the pattern you mentioned, so I'm hoping it'll work now!
Something very weird is that when I went into the item's settings (via Item Details page) and tweaked something unrelated, then went back to the item's Overview, the URL went back to what I described in my original post! No!! But then I closed and reopened the item's Item Details page. Then the URL was back to the utility.arcgis.com pattern. What the heck? Anyway, I'm glad that I now have access to that correct URL, and I have learned to close and reopen the item to get it.
If anyone from Esri is reading this... I am curious whether the behavior I described above is a bug (where the URL of my "copy" of the routing service changes back to the generic URL (https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World) after I go into the content item's settings, but then when I close and re-open the Item Details, the URL is back to a unique one that points only to my specific content item rather than Esri's source (https://utility.arcgis.com/usrsvcs/servers/ [unique string here]/rest/services/World/Route/NAServer/Route_World)
Is this a bug?
Thank you!
When I create a new item on www.arcgis.com that points to the route service, I am unable to reproduce the behavior you are observing. Can you verify if you see the same problematic behavior on a new item?