Select to view content in your preferred language

Is it possible to get a list of outside organization groups shared with my organization members.

672
1
3 weeks ago
Labels (1)
ClaytonBurns2
Occasional Contributor

When using the gis.group.search() function it only returns groups that are owned by members of my organization. As an organization admin I'd like to see all the groups that are owned by members of other organizations, but that my members have shared access to. Similarly to how the filter in ArcGIS Online Groups tab currently works. Is this possible within the ArcGIS Python API? I can't find anything in particular in the modules documentation that shows how it can be done.

https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#group

ClaytonBurns2_0-1755189119768.png

 

0 Kudos
1 Reply
Clubdebambos
MVP Regular Contributor

Hi @ClaytonBurns2.,

I was never able to figure that out myself and the API documentation is outdated (print the python help as shown in the snippet below to see). You can however invoke the REST API as per below. Code commented. Let me know if anything needs clarification. 

from arcgis.gis import GIS

## access ArcGIS Online
agol = GIS("home")

## your orgnanisation's ID
orgId = agol.properties.user.orgId

## the username you want check has access to what outside groups
username = "USERNAME"

## use the REST API URL and get the return as JSON
groups = agol._con.get("{0}/sharing/rest/community/groups?searchUserAccess=groupMember&searchUserName={1}&q=-orgid:{2}&f=json".format(agol.url, username, orgId))

## print the groups variable to see what is returned
##print(groups)

# print out some infor for each group
for group in groups["results"]:
    print(group["title"], group["id"], group["owner"])

## if you want to see the groups search syntax (differs from docs)
## there is an outside_org param but never got it to work properly
##print(help(agol.groups.search))

All the best,

Glen

~ learn.finaldraftmapping.com
0 Kudos