Exact same Notebook in AGOL vs. Local ArcGIS Pro

194
0
02-04-2024 11:39 PM
Labels (1)
JasonBatory
New Contributor

I'm relatively new to AGOL Notebooks so forgive me if this is obvious. I have done a lot of Googling and haven't been able to find any answers...

I'm confused as to why this exact same code works in my local install of ArcGIS Pro Notebooks but not in ArcGIS Online (using "Advanced"). I have also tried generating and adding a token to the url with same result (works without token locally):

 

from arcgis.gis import GIS
import arcpy 
gis = GIS(<portal>, <portal_username>, <portal_password>)

myLayer = gis.content.get(<item_id>)   
url = myLayer.layers[0].url
with arcpy.da.SearchCursor(url, "*") as cursor:
    for row in cursor:
        print(u'{0}, {1}, {2}'.format(row[0], row[1], row[2]))

 

Local version I get a list of rows, AGOL version I get this error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_33/2031414702.py in <cell line: 3>()
      1 myLayer = gis.content.get(<item_id>)
      2 url = myLayer.layers[0].url
----> 3 with arcpy.da.SearchCursor(url, "*") as cursor:
      4     for row in cursor:
      5         print(u'{0}, {1}, {2}'.format(row[0], row[1], row[2]))

RuntimeError: cannot open 'https://services.arcgis.com/NxaIos6bsLPQJAmb/arcgis/rest/services/<removed>'

 

Any help appreciated.

Jason

0 Kudos
0 Replies