How to script AGOL Metadata Editor 'save' function to enable file geodatabase download option in AGOL Open Data?

775
0
03-01-2021 03:28 PM
StaceyPlumley
New Contributor II

Hello -

I use this Python script to upload XML, ArcGIS formatted metadata to items in AGOL. The items are registered feature layers of ArcGIS Server map services.

The XMLs have been edited to enable a zipped file geodatabase download in our AGOL Open Data Site. The geodatabase download only becomes available in Open Data after I run the script and then manually open the AGOL metadata editor for that item and click the 'save' button.

I haven't found a way to script the Metadata Editor 'save' function with the ArcGIS API for Python. Anybody know how?

Thanks!

Stacey

 

import os, csv
from arcgis.gis import GIS

#Set path, user ID, and password to AGOL account
userid = "username"
gis = GIS("AGOL URL", userid, "password")

#Set variables
userfolder = "folder name"
csvdata = "path to csv"
xml_path = "path to xml folder"

#Get a list of items in AGOL folder
user = gis.users.get(userid)
itemslist = user.items(folder=userfolder, max_items=500)

#Iterate through AGOL items and CSV records
for item in itemslist:
    csv_reader = csv.DictReader(open(csvdata))
    for row in csv_reader:
        namefield = row['AGOLTitle']
        xmlfield = row['XMLName']
        add_xml = os.path.join(xml_path, xmlfield)
        #Update AGOL items that match CSV records
        if item.title == namefield:
            item.update(metadata=add_xml)
        else:
            continue
del item

 

0 Kudos
0 Replies