Select to view content in your preferred language

403 Error when overwriting feature layer in ArcGIS Online

07-12-2023 03:45 PM
Labels (1)
New Contributor

I'm attempting to overwrite a hosted layer that I own in ArcGIS Online using the arcgis.features.FeatureLayerCollection.manager.overwrite() method in Python. When I login to AGOL normally it redirects me to my organization's sign-in page so I'm using OAuth2.0 to authenticate in Python. When using my client_id and client_secret I can read my hosted layers but I'm unable to overwrite them. When attempting the below code I receive a 403 Error. 

from arcgis.gis import GIS
    from IPython.display import display
    import os
    import glob
    import pandas as pd
    directory = r'G:/Shared drives/path/'
    file_pattern = '*.csv'
    latest_file = max(glob.glob(os.path.join(directory, file_pattern)), key=os.path.getctime)
    df = pd.read_csv(latest_file)

    from arcgis.features import FeatureLayerCollection
    gis = GIS("", client_id = "XXXXXXXXXXXX", client_secret = "XXXXXXXXXXXXXX" ) 
    fs = gis.content.get('XXXXXXXXXXXXXXXXX') 
    fs = FeatureLayerCollection.fromitem(fs)

The feature layer also has editing enabled. Is it possible to overwrite or even publish a hosted feature layer using OAuth2.0 in ArcGIS API Python? 

Tags (1)
0 Kudos
1 Reply
Esri Contributor

It sounds you're encountering the Limitations of application credentials which do not allow updating. You can Application logins are limited in what they can do. You can use Pro authentication to accomplish your workflow:

gis = GIS("pro")