Select to view content in your preferred language

Find out what a user has been doing in your organization

5084
8
03-15-2019 04:06 PM
KellyGerrow
Esri Alum
3 8 5,084

The History endpoint of the REST API is a great tool to dig into information about events occurring in your organization. Although you easily download a comprehensive CSV of events as an administrator in ArcGIS Online, the REST API, provides the option to customize the data returned and to ask more specific questions. For an example of how to use the history CSV, check out this blog: https://www.esri.com/arcgis-blog/products/arcgis-/administration/exploring-the-organization-activity... 

 

For this blog I am going to outline the query and results about a specific member of my ArcGIS Online organization.

 

Scenario: It’s time for Karate_Kelly’s year end review. She wants to prove to her boss that she has been busy creating and managing content in the organization. Using the History API, She’ll query all of the events that she has initiated in 2018.

 

Detective Steps:

  1. Formulate the Query

Url: https:/webapps.maps.arcgis.com/sharing/rest/portals/self/history?

Parameters:

all=true – returns events for all members in the organization

start=0 – Starts at the first record

num=10000 – largest amount of events returned (requires csv format)

f=csv – Returns result in a csv

sortOrder=asc – information output in ascending order

token = “6hVsODGfBpk5X_hGc0MOrnxmddIk4bL4hP8FyOAxM0QxL3VEw86iTdB” – admin token required

fromDate =2018-01-01 – start of date range

actors= Karate_KElly – events to be returned (Note, usernames are case sensitive, so if you hit a key by accident while creating your username, check the casing just to be sure... #Karate_KEllyIsNotAMistake)

Sample Url constructed:

https://webapps.maps.arcgis.com/sharing/rest/portals/self/history?all=true&start=0&actors=Karate_KElly&sortOrder=asc&fromDate=2018-01-01&num=10000&f=csv&token=Qian2inO2Cqf0tsljaLVJC5YbmjpQvg-CQ565QE75vesENzX5Yorf40K4ai_7fHn8

  1. Submit the request and view the resulting CSV
  2. Perform analysis or use pivot tables to provide insight into actions

ActionCount of Actions
Add412
Add Users7
Create12
Delete104
Failed Login15
Login192
Remove Users1
Share252
Update1448

Tracking my events by Month:

JanFebMarchAprilMayJuneJulyAugSeptOctNovDec
# of Actions10185727427614829149129101261445

Test: When did I go on Summer vacation last year?

This is a neat way to look at your actions and your organizations members actions over time.

*Note. Only available in ArcGIS Online

https://community.esri.com/community/gis/web-gis/arcgisonline/blog/2019/03/16/generate-a-token?sr=se...

8 Comments
GregoryLund2
Occasional Contributor

Thank you for posting.

I'm not a developer, and apologies for the stupid questions.

I am the AGOL Administrator at my University and would like to try this, but need some assistance.

Is it me, or is this what I should see at your: "1. Formulate the Query, Url: https:/webapps.maps.arcgis.com/sharing/rest/portals/self/history?" =

image of self/history

When I utilize my address: "uwt-gis-geotech" the result is the same:

image2

is this the proper sample path?

I'm not seeing wehre the '&31' is from.

Again, thank you for posting, and apologies for the silly questions.

Regards,

Greg

KellyGerrow
Esri Alum

Hi Greg,

My bad, there was a typo in the sample url. I have fixed it up now (no 31&) needed, but be warned the token isn't valid so you won't be able to successfully load the sample url.

For your url try,

https://uwt-gis-geotech.maps.arcgis.com/sharing/rest/portals/self/history?all=true&start=0&actors=<enterusername>&sortOrder=asc&fromDate=2018-01-01&num=10000&f=csv&token=<add your admin token>

Using the URL should result in a csv being downloaded automatically. Let me know if that gets you up and running or if you have more questions. 

I'll post another blog about how to get the token, just in case it comes up.

Thanks,

Kelly

JTessier
Frequent Contributor

Do you have plans to include this as part of On-premise ArcGIS Enterprise?  If so at what version?

Thanks!

J

Jason Worrel

AndrewRudin1
Frequent Contributor

Is there a way to obtain this admin token programmatically via the REST API?  Is it different then the token obtained by the/sharing/rest/oauth2/authorize endpoint or the /sharing/rest/generateToken endpoint?

I ask because I'm trying to get an ETL tool to retrieve data from the AGOL REST API's portal_history endpoint via my federated admin account, but the authentication documentation for the API sends me in circles for this type of Portal administrative workflow where I just need to connect to the ArcGIS Online Org or Enterprise Portal and query out some details about users, items, licenses, etc.

I assume the code is as basic as two lines

1) Submit REST call containing my credentials to obtain the token

2) Submit REST call to the Portal_History endpoint containing my credentials

PhilipSacca
New Explorer

I am using Arcgis Portal on premise, when I try the history end point I get 

Unable to retrieve history?


Error: 500

https://xxxxvpor01.xxxsky.lab/portal/sharing/rest/portals/self/history?token=JJGZ7vaLd3E_WSpkC_n84ho... 

MaxSquires
Frequent Contributor

the same message is returned from the python api for arcgis.

from arcgis.gis import GIS

gis = GIS(portal_url, "siteadmin", secret)

gis.admin.history(start_date=datetime.datetime.today())

>> 'C:\\Users\\<user>\\AppData\\Local\\Temp\\history.csv'

contents of history.csv:

{"error":{"code":500, messageCode:"DB_0279", message:"Unable to retrieve history.", details:["Unable to retrieve history."]}}

 

frdchp2021
New Contributor

hi, Do you get any work around about history ?  (I got the same wonder if somebody answered this)

 

 

SoledadPons_Martinez
Occasional Explorer

Hi @KellyGerrow , 

I am working in a ArcGIS Enterprise On-Premise Portal. When I tried the /history endpoint I get the following:

{"error": {
 "code": 500,
 "messageCode": "DB_0279",
 "message": "Unable to retrieve history.",
 "details": ["Unable to retrieve history."]
}}

 I know /history is only available for ArcGIS Online.

Could you tell us if there's an alternative tool to obtain the same within ArcGIS Enterprise?
I'm working with version 10.8.1 and I've heard about Activity Dashboard extension but I'm not sure if it could be useful as well to track users activity.

Thanks in advance, 

S.

About the Author
I love interactive maps and apps on the internet! The maps and apps that customers create and share on the web, make my job awesome. I'm a Product Manager with the ArcGIS Online team in Redlands, California. I am a proud graduate from Carleton University and the COGS in Canada, with research focus' in Health Geography. Originally from Bedford, NS, Canada but have spent a lot of time in Haliburton and Ottawa, Ontario. I have a passion for the outdoors and dogs.