I have a public REST service that has several layers and feature classes that I want to access. According to the documentation. Once I have the arcgis
package imported, I can inject my outside REST service as such:
*Note: I am using the Jupyter Notebook to test this code.
from arcgis.gis import GIS
gis = GIS("https://hazards.fema.gov/gis/nfhl/rest/services/CSLF/Prelim_CSLF/MapServer")
Since this is a public service, I didn't have to include any username or password parameters. The service has several layers (item_type="Feature Layer) that I want to access; namely Special Flood Hazard Area Change layer, but perhaps others:
Using the example from the API docs, I tried to do a search in the service just to see all the layers and any info I might need in future calls. I am using the '.search' method from the content manager.
# search and list all feature layers in my contents
search_result = gis.content.search(query="", item_type="Feature Layer")
search_result
Every time I try this, I get an either a KeyError='num'
or a TypeError: must be str, not int
(if I try to add a query). What am I doing wrong here and what is the proper way to search within this REST service?
Best Answer
This answer actually came from someone on GeoNet but I wanted to post it here in case someone else runs into this problem. In a nutshell, the mod
GIS
was designed for use with an arcGIS Online account, Portal, or ArcGIS Enterprise Server, not an outside service.:
This answer also worked well. Hope this helps someone with similar issues.