I have listed the layers for a map service using the "layers" property on an ArcGISMapService object.
elif lyr.layerType == 'ArcGISMapServiceLayer':
if 'layers' in lyr:
for l2 in lyr.layers:
# print(str(len(lyr.layers)))
print(" >>> "+str(l2.id))
I only get information for 2 layers out of 24. I'm sure this is the right map service, and the 2 layers that I get information for have the same id as they do in the full list I get when I directly check the map service in the portal. I've checked the json directly - only 2 layers are in it.
Obviously, I could be making an error that I can't expect anyone here to diagnose, but I think there is something unusual going on here that someone might recognize as a common newbie mistake? Is this a common problem? Might the map service be corrupted? How would I check that? When I check the map service in the portal, I see all layers listed, and it works fine when it is loaded into a web map.
Bit of a Hail Mary here. Thank you for any help you may be able to provide.
Randy McGregor
Is the service publicly available? If not, can you reproduce what you are seeing using a service that is publicly accessible?
If the JSON being returned from the REST call from the server looks incorrect, you might want to post your question over at ArcGIS REST API, since the ArcGIS Python for API is mostly a wrapper for the REST API.
It's not publicly available, but thank you for asking. It would be hard to create a publicly available service that reproduced this. Thanks of the information on the relationship between the REST API and the ArcGIS API for Python. I've suspected that, but am too new to this to have a firm handle on it. Training is $$, but I may have to suck it up.
Randy