Search code examples
restarcgisesriarcgis-serveresri-arc-engine

Get Portal url (Host url) in ArcGIS Online Rest API


I am new to Rest API and trying to develop a client for ArcGIS Online. I tried to login to ArcGIS.com using my login credentials and then see the maps that I have posted on the server. When I click on any map, it opens up in browser with a url like this.

https://services.arcgis.com/N2SwjtBNabcd069C/arcgis/rest/services/IMap/FeatureServer/1

Then I created a different login account, and then published map and tried to open that in browser it showed up with a different url like this

https://services2.arcgis.com/N2SwjtBNabcd069C/arcgis/rest/services/IMap/FeatureServer/1

Note the start of the url first one is

https://services.arcgis.com/

and second is

https://services2.arcgis.com/

Now my problem is when I try to login in my client application that I am developing. I am able to generate the token, account id and account name. But how do I know which server should I search for to locate my layers(i.e. services2.arcgis.com or services.arcgis.com)? Where can I get this information from

P.S: N2SwjtBNabcd069C in above url is the account id


Solution

  • After you login, and generates your token you can make the following query to see the url of your content.

    http://www.arcgis.com/sharing/content/users/<username>?f=json&token=<generatedToken >

    This will return you the json that contains the url of your service.