Obtain a list of all ArcGIS Online content for an organization using the REST API?

7150
3
02-12-2015 11:17 AM
EricDaniel1
New Contributor

I'm looking for a way to retrieve all the items (web map, feature service, map service, geocoding service, etc) shared within an organization's ArcGIS Online account.  I would think this is not that uncommon of a request, but I have not been able to find any examples on how this can be accomplished.

I'm using OAuth 2 authentication and can successfully get a valid token for the user.  I see that I can use https:www.arcgis.com/sharing/rest/content/users/<username> to get all the items owned by the user, but I'm interested in all items available to this user for the organization.  Items created by others in the org and either shared within the org or shared publicly.

I've looked into the https:www.arcgis.com/sharing/rest/portals/self but that is also not providing all the content available to the user.

Basically, I'm looking for a programmatic way using the REST API to obtain all the content that is available to the user if they were to login to their organization's AGOL account and go under Gallery>>My Organization's Featured Content.

Any suggestions would be appreciated.  Thanks.

Tags (2)
3 Replies
BenNadler
New Contributor III

Look at the ArcRest python package. It allows you to do this: Esri/ArcREST · GitHub

This example will report content by groups:

ArcREST/report_content_in_groups.py at master · Esri/ArcREST · GitHub

StevenDel_Favero
New Contributor

This is how to loop through a folder for a user. Combine this with a loop through each user in an Org...

admin = arcrest.manageorg.administration.Administration(securityHandler=sh)
content = admin.content
user = content.users.user(uname)

# Iterate through all content in each folder
for folder in user.folders:
      fName = folder['title']
      user.currentFolder = fName
      print ('--------------------------------------------')
      print ("In Folder: {}".format(fName))
      for item in user.items:
            print " - {}".format(item.title)

sedot
by
New Contributor

Only 5 years too late and having the same problem, I managed to solve this:

When querying the Search API, use the organization ID as the value for the query parameter "accountid". This is mostly undocumented. I only found it by watching how AGO Assistant uses the REST API.

This only works using named user login authentication, not with app authentication, which is what we want. So it will probably work for you. (But not for me and I didn't solve it after all 😞 )

 ?q=accountid:xxxxxxxxxxxxxxxxx 

0 Kudos