Access user group membership through REST API using agoTools and Python

957
2
09-05-2014 04:26 PM
HeathBrackett1
Occasional Contributor II

I'm trying to access the user['groups'] property using a python script that calls the getUsers from agoTools.  I can access the users and get information, but the 'groups' property (described as a json array) seems to be empty?  I may just be accessing it incorrectly.

I am assigning the 'groups' property to a numpy array but the array comes up empty.  Any suggestions?

for user in users:

    UserGroupList = numpy.array(user['groups'])

    print UserGroupList.shape

produces a long list of:

(0,)

(0,)

(0,)

(0,)

...

0 Kudos
2 Replies
AlexanderNohe1
Occasional Contributor III

Hi Heath,

I have never had much luck with agoTools and instead I use portalpy which seems to be a little more friendly.  You may want to consider trying portalpy rather than agoTools for what you are trying to do.

Esri/portalpy · GitHub

While although this is a different module, I think you may find this module a little bit easier to use.

I hope this helps!

Thanks

HeathBrackett1
Occasional Contributor II

Hi Alex,

I ended up using the Esri/ArcREST - GitHub module for some of the processes that I needed to do.  It worked.  I didn't know about the Esri/portalpy tools though.  Thanks for sharing that link.  I'll look into incorporating those into my scripting.

Heath

0 Kudos