Best approach for a workflow API Python & arcpy?

871
13
06-12-2019 02:28 PM
deleted-user-yC5VkbyXzrQR
Occasional Contributor

I'm trying to update our sde with a hosted feature layer. 

What is the best approach for this. I'm aware of the API Python and Arcpy.  I'm a little confused on how to start of this script. I have a fair amount of knowledge with arcpy and have created complex scripts with it. 

The goal is that this script will run automatically or when ever I want it to. Basically I want to take a hosted feature layer that is a copy of our database and update changes that were captured in the Hosted Feature Layer back to our database. 

Do I use the API for Python to connect to the Hosted feature layer or can I use Arcpy for that? Would I use both the arcgis python API and arcpy ?

Any guidance would be appreciated! 

Thanks, 

Adam 

0 Kudos
13 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Adam,

ArcGIS Pro's Feature Class to Feature Class tool will download the hosted feature class.  You could create a model to download the feature class, truncate the Enterprise Geodatabase feature class, then append the downloaded feature class to the Enterprise Geodatabase feature class. 

Also, here is another tool that will download a hosted feature service that works in ArcGIS Pro and ArcGIS Desktop:

https://community.esri.com/docs/DOC-6496-download-arcgis-online-feature-service-or-arcgis-server-fea...

deleted-user-yC5VkbyXzrQR
Occasional Contributor

Thanks Jake! 

So there's no need to use ArcGIS API for python? 

What do you mean by turncate what does this do? does this delete everything in the enterprise database? I don't think that I would want to do this, I really just want to update 1 field. 

Also i tried the tool and I can't get it to create a token. We use OKTA to login into our ArcGIS online accounts. I think thats where the problem occurs, because if I make it public it works no problem. 

Generating Token


URL is incorrect. Or, Service is secure, please enter username and password.

Completed script DownloadService...
Failed to execute (DownloadService).
Failed at Wed Jun 12 21:31:18 2019 (Elapsed Time: 1.12 seconds)

 

Any ideas ? 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Correct, you won't need to use the ArcGIS API for Python. 

Yes, a truncate will delete all features in the feature class.  If you want to update a field, you could perform a join to the downloaded feature class and then a Field Calculation to calculate the values over.

The tool I shared won't be able to authenticate with Okta.  It will be best to connect to ArcGIS Online in Pro and use the Feature Class to Feature Class tool to download the data.

deleted-user-yC5VkbyXzrQR
Occasional Contributor

Yeah I got it to work that way. So to run this script I would have to log into Pro. I couldn't have this script to run automatically, say over night ? 

This tool is amazing by the way! 

Thanks for the share. 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Yes, could update the #Variables at the beginning of the script.  Ex:

You can then use Windows Task Scheduler to execute the script.  If you can, I would see if you could create an ArcGIS Online built-in account so that you don't have to share the service with Everyone.  Then you can share this service to a Group that user is a member of.  That way you use these credentials to create the token and download the service.

deleted-user-yC5VkbyXzrQR
Occasional Contributor

Jake, 

I ran into this error using your tool. I can't find any info on it on. Do you have any idea whats going on ? 

LINE: 292
"fs.load(fsURL)": RecordSetObject: Cannot load a table into a FeatureSet.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Adam Arcichowski‌ if you share the service to a Group and then invite my AGOL account (jskinner_CountySandbox) I can take a look to see what's going on.

0 Kudos
deleted-user-yC5VkbyXzrQR
Occasional Contributor

Thanks Jake.

But I found a work around. I just added the data with a path in arcpro 

with arcpy. 

0 Kudos
deleted-user-yC5VkbyXzrQR
Occasional Contributor

Hey Jake I've been using your tool for lots of data out there. 

However I can across this error now. Do you know why? Do some datasets not allow you to download their data? 

Specifally this data https://gis.bisclient.com/maps03/rest/services/RedRiverWeb/MapServer/0 

0 Kudos