Delete records in a feature class in AGOL (Survey hosted in AGOL)

344
1
11-16-2022 12:49 PM
Labels (1)
GeoffroyVan_Dyck
New Contributor

I want to delete some records in a feature class hosted in our portal (like agol)

I use this code:

########################################################################################################################

# Main program #########################################################################################################

########################################################################################################################

try:

    portal_url="https://organization.arcgis.com"

              username="<username>"

              password="********"

              proxy_Host='10.x.x.x'

              proxy_Port= 8080

    ########################################################################################################################

    # Connexion to internet site

    gis = GIS(portal_url, username, password, verify_cert=False, proxy_host=proxy_Host, proxy_port=proxy_Port)

    print("Credentials Verified")

    ########################################################################################################################

 

    # delete records in hosted survey

    Item_ID = '<item_ID>'

    data_item = gis.content.get(Item_ID)

    print(data_item) -> response   <Item title:"A Survey [DTA]" type:Feature Layer Collection owner:username>

 

    #layer

    featurelayer=data_item.layers

    print(featurelayer)

   layer=featurelayer[0]

 

    print(layer) -> response <FeatureLayer url:"https://services7.arcgis.com/xxxxxxxxxxxxxx/arcgis/rest/services/service_xxxxxxxxxxxxxxxxxxxxxx...">

 

  Here, I want to delete the records ….

except Exception as e:

    print(e)

   

finally:

    print('Process Done'

 

 

But here, I’m blocked … Any ideas ?

0 Kudos
1 Reply
Clubdebambos
Occasional Contributor III

Use the delete_features function as shown in the API Docs.

~ Mapping my way to retirement