arcpy.da.searchcursor with non-public ArcGIS Online service

235
2
08-19-2021 09:30 AM
JoshKalovGIS
New Contributor III

Hi all,

I am trying to figure out the right way to get arcpy.da.searchcursor working with an ArcGIS Online service that is not public. I have the service shared to an ArcGIS Online group and my user is a member of the group.

I know I can use arcpy.SignInToPortal to sign into portal with my user and then I think arcpy.GetSigninToken() to get the token from that sign in.

I tried adding the token as a parameter to the service url but that didn't seem to work.

Has anyone successfully used arcpy.da.searchcursor with an AGO non-public service?

Thanks

Josh

0 Kudos
2 Replies
Jeremy_Moore
MVP

Welcome!

It might help for you to explain what you are trying to accomplish or what your goal is. This will help us guide you in the correct direction. 

When interacting with ArcGIS online hosted services we use REST. ESRI has created an awesome API for us to use that wraps REST in python. It is called the ArcGIS API for Python. I highly recommend that you take a look at the API and some of the tutorials.

You can access the API reference from here:

https://developers.arcgis.com/python/api-reference/

Here you can access the guide for the API. Take a look at the getting started section. This will help you login to ArcGIS Online VIA python and help you get going on your journey. 

https://developers.arcgis.com/python/guide/ 

Once you have familiarized your self with the ArcGIS API for Python. You want to take a look at the arcgis.features module. This module will allow you to work with the data in the hosted feature service. You can do things like access fields, properties, update, add data, delete data, append, calculate and more. Within the arcgis.features module there is a class called the FeatureLayer Class. You can directly query features with this class. 

arcgis.features module:

https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#

FeatureLayer Class: 

https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#featurelayer 

 

If you have any questions, please do not hesitate to ask. There are no dumb questions.

Hope this helps

0 Kudos
JoshKalovGIS
New Contributor III

Hi Jeremy,

Thank you for replying. My goal is to download records from an ArcGIS Online Hosted service using the arcpy searchcursor method. I am aware of the ArcGIS Python API. We do use that. Unfortunately, we started having some intermittent issues with the query so I temporarily switched to using arcpy searchcursor to get records.

So I am trying to find out the correct way to use arcpy searchcursor with a non-public ArcGIS Online hosted service.

Thanks
Josh

0 Kudos