I'm writing code for a notebook that will search for a specific item in my content.
def getFeatureLayer(layername, i=0):
queryString = 'title: ' + layername + ' AND owner: ' + gis.properties.user.username
print (queryString)
layer = gis.content.search(query = queryString, item_type = 'Feature Layer')
if len(layer) > i:
return layer
else:
return
import csv
with open('data/users.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
user = gis.users.get(row['username'])
searchlayer = 'WCC_' + row['groupname']
print(searchlayer)
layer = getFeatureLayer(searchlayer)
print(layer)
However, this is not returning layers that exist in my content.
WCC_1Testing title: WCC_1Testing AND owner: Ken.Buja_noaa None
I've tried this with other content that I own and it doesn't return the item either.
If I try this with content elsewhere in the organization, it does return layers. Is this because my content that I'm search on hasn't been shared with the organization?
Solved! Go to Solution.
This was a bug in version 1.5.1
When logging into AGOL with OAuth2.0 using an Enterprise account, the admin module is not included in the GIS object, so only public items are returned in a search. If you connect to AGOL with a built in account (using a username and password), the GIS object does contain the admin module, so all content is returned.
This bug was fixed in 1.6.
This was a bug in version 1.5.1
When logging into AGOL with OAuth2.0 using an Enterprise account, the admin module is not included in the GIS object, so only public items are returned in a search. If you connect to AGOL with a built in account (using a username and password), the GIS object does contain the admin module, so all content is returned.
This bug was fixed in 1.6.