Programmatically download xml metadata files from ArcGIS Online

10-15-2020 09:37 AM
New Contributor III

Can a python script in ArcMap be used to download the metadata.xml files for all items in my ArcGIS Online account into a local folder?  If anyone has done anything like this I'd really appreciate some help.  I can update the metadata.xml file using:

def update_metadata(user, item, token, metadata):
    d = {"overwrite": "true",
         "token" :token,
    f = {'metadata': ('metadata.xml', open(metadata, 'rb'), 'text/xml', {'Expires': '0'})} 
    url = r'{0}/items/{1}/update'.format(user, item)
    r =, data = d, files = f)

    response = json.loads(r.content)

    if 'error' in response.keys():
        raise Exception(response['message'], response['details'])

    return response


0 Kudos
1 Reply
MVP Notable Contributor

According to the API help file you can download metadata for an item, see here.

0 Kudos