I'm not having luck with the GlobalID and ParentGlobalID columns when attempting to populate Feature Classes and Tables in a FGDB from a hosted feature service. It's all fairly straight forward and seems to work just fine, except for when specifying these two fields.
Issues:
1. The GlobalId field does not seem to throw any error, however the feature classes get populated with the value: {00000000-0000-0000-0000-000000000000}
2. There's also related feature classes that contain a ParentGlobalID column as well, these throw an error when attempting to load the feature set "RuntimeError: RecordSetObject: Cannot open table for Load". If I remove the "ParentGlobalID" column from my list of fields to download, then the process works fine without error (minus the ParentGlobalID column of course).
This is the important section:
fields = """objectid,globalid,SurveyStartTime,SurveyEndTime,CreationDate,Creator,EditDate,Editor"""
taburl = <URLtoHostedFeatureService>/query/0
where = '1=1'
query = "?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, '*', token)
queryfsURL = taburl + query
#try to convert the hosted service to a fgdb table
fs = arcpy.FeatureSet()
fs.load(queryfsURL)
fs.save(r'<pathToDirectory>\downloadTab.gdb\HostedFsNameHere)
#also attempted this
#arcpy.CopyRows_management(fs, r'<pathToDirectory>\downloadTab.gdb\HostedFsNameHere)
Solved! Go to Solution.
Moving latest testing results out as reply to OP:
1. Run with the python window in ArcGIS Desktop 10.3.1 with both Background Processing checked and unchecked generates the 0's
2. Run as .bat pointing to C:\Python27\ArcGIS10.3\python.exe generates 0's
3. Run as .bat pointing to C:\Python27\ArcGISx6410.3\python.exe generates 0's
4. Run with the python window in ArcGIS Desktop 10.4.1 with both Background Processing checked and unchecked generates the expected GlobalID values.
5. Run as .bat pointing to C:\Python27\ArcGIS10.4\python.exe generates expected GlobalId values
6. Run as .bat pointing to C:\Python27\ArcGISx6410.4\python.exe generates 0's
What version of server and client are you running? I just tested your general steps using a feature service from ArcGIS Enterprise 10.5.1 and ArcGIS Pro 2.1 and the GlobalIDs are intact.
ArcGIS Server 10.4 (maybe 10.4.1)
ArcGIS Desktop 10.3.1
Good point -- I do have a 10.4 client I use to publish GP services but I didn't run this particular script on that box. I only ran (with my issues) on the 10.3 install.
I'll check that out!
Thank you.
Thanks again,
I ran the script from a client with ArcGIS Desktop10.4 installed but has the same issue with GlobalID -- it creates the feature class without error including all of the fields specified, but the globalId column is populated with {00000000-0000-0000-0000-000000000000}
Also: this is a hosted feature service on AGOL that I'm working with.
From the Feature Service end point:
I only have access to an ArcMap 10.6 machine today, but I tested the same feature service I used to test with Pro 2.1, and the GlobalID field carries through fine. So, it is either a hosted-feature service issue or client version issue. I will test an older client and AGOL hosted feature service sometime soon.
Much appreciated.
I was experimenting with your script and was able to get a feature from AGOL with the global ID intact. Since this is a URL request, I was wondering if the "where" clause might be part of the problem. Normally the 1=1 would be encoded as 1%3D1 (%3D would be the equals sign). Edit-- I did another try using where=1=1 (without escaping the equals sign) and was able to get the global IDs.
Have you examined the returned json before inserting it into your database to verify the global IDs?
Good call, Randy. I did as you suggested and set a search cursor on the FeatureSet() after .load() to see what the GlobalID values are at that point (before converting to fgdb Feature Classes / tables).
You're test validates that they are {00000000-0000-0000-0000-000000000000}
When queried on the REST endpoint (WHERE 1=1, Fields = *) I see the globalid and parentglobalid values as expected.
with arcpy.da.SearchCursor(fs, ['objectid','globalid']) as fscur:
for fsrow in fscur:
print fsrow[1]
##result:
globalid
{00000000-0000-0000-0000-000000000000}
{00000000-0000-0000-0000-000000000000}
{00000000-0000-0000-0000-000000000000}
Have you examined the returned json before inserting it into your database to verify the global IDs?
Response on the request from Dev Tools Response tab is:
"features" : [
{
"attributes" : {
"objectid" : 2,
"globalid" : "9667a224-a732-49f3-b3c2-3eafb17a482d",
I have published a new feature service from a different feature class source (containing globalid's) and re-running the script produces the same {00000000-0000-0000-0000-000000000000} globald values.