I am running this code on AGOL Notebook but I am getting error. The code is from Esri website
I don't know why I am getting this error:
This is exact code on blog except I am running it on Notbook on arcgis online. Then I didn't provide password and a portal url just user name
import arcgis from arcgis.gis import GIS user = "UserName" ##My User name ##for web maps webmaps = gis.content.search("owner:" + user, item_type="Web Map", max_items=10) webmaps ##for feature layers fcs = gis.content.search("owner:" + user, item_type="Feature Layer", max_items=10) fcs ##for feature layers fcs.url fc_layers = fcs.layers fc_layers.url ##for web maps web_map_obj = arcgis.mapping.WebMap(webmaps) maplayers = web_map_obj['operationalLayers'] maplayers['url']
Have u tried working with for loops and/or list indexes?
In the example, they probably have only 1 webmap and 1 feature layer. If you have multiple webmaps en feature layers, the result of gis.content.search will be stored as a list.
To extract all feature layer URLs you can for example try:
for i in fcs: print(i.url)
It is also possible to work with list indices.
Hope this will help you out.