Python is no longer seeing hosted feature layers from server.

1134
12
Jump to solution
11-16-2022 06:50 AM
ColeHowell
New Contributor III

I've encountered a problem with some scripts that used to work but are now no longer functioning. I was using arcpy to update the fields to a hosted feature layer stored on the server my company uses for gis. All of a sudden, today when I go to run the script it gives a runtime error and says that it cannot open the layer I'm updating. To try and troubleshoot what happened, I decided to print the list of feature classes in storage location but the list returned says "None". I then tried running another script that is utilizing a different hosted feature layer but that script failed in the same way. Is this a problem with my computer or the server? Like I said, all these scripts were working yesterday and I came in this morning and they're acting broken. 

 

import arcpy

#access the DMA layer
arcpy.env.workspace = <server URL>
arcpy.env.overwriteOutput = True

#this is how I found the name of the feature class as it was stored online
tables = arcpy.ListFeatureClasses()

print(tables)

 

This is the code that is giving me trouble.

0 Kudos
1 Solution

Accepted Solutions
ColeHowell
New Contributor III

This question led me to check pro and it turns out I was signed out of my account. When I signed back in my code started working again so I would just like to acknowledge the contribution here. I don't know if these are related issues but sometimes it's the simple things.

View solution in original post

12 Replies
by Anonymous User
Not applicable

Were there any recent windows updates that got installed?  Are you using the full server http url, or pointing to it as a directory path?

Just a tip, if you are working with servers and hosted data, using the arcgis for python api may be more suitable for your operations.

ColeHowell
New Contributor III

The last windows update installed was a few days ago and the script was still working then. I have been using the full server http url. I'll have to look into the arcgis for python api. I'm pretty new to arcgis in general so there are still things I'm learning.

0 Kudos
by Anonymous User
Not applicable

Try using just the server path to the folder?  \\servername\fldr\fldr\fldr\etc...

0 Kudos
ColeHowell
New Contributor III

Do you know where I could find that path? It's not entirely obvious from the item details on enterprise where I would get it.

0 Kudos
RhettZufelt
MVP Frequent Contributor

The way URL's are listed in the items details page changed a version or two ago.

Is the URL you are using similar to https://services#.arcgis.com OR https://yourorg.maps.arcgis.com ?

If it is the "yourorg" format and not the services path, it will return None, but using the actuall services path ( in my case https://services3.arcgis.com/5g...b/arcgis/rest/services/FeatureClassName/FeatureServer) the code you posted is working fine.

R_

ColeHowell
New Contributor III

It's more similar to the version you said was working for you. My company is using enterprise for our gis. Would that change anything?

0 Kudos
RhettZufelt
MVP Frequent Contributor

Often, you can get it from the items details page (the copy icon, not the View link):

RhettZufelt_0-1668624539589.png

Not sure about Enterprise, no way for me to test that.  However, if it is issues with tokens, this post may help.

R_

MichaelMixon
New Contributor II

Without using python, are you able to add the feature services to ArcGIS Pro using the Add Data button in the application? We began having problems last week and are unable to add feature services from ArcGIS online. I just wonder if these issues are related?

ColeHowell
New Contributor III

This question led me to check pro and it turns out I was signed out of my account. When I signed back in my code started working again so I would just like to acknowledge the contribution here. I don't know if these are related issues but sometimes it's the simple things.