AnsweredAssumed Answered

Metadata not loading to item via API

Question asked by ivangis on Jan 11, 2018

I haven't been able to get metadata to load through the API (ArcGIS API for Python 1.3). I have many pre-existing ArcGIS Online items to which I want to reload new metadata files (as a scripted bulk task). I wrote and ran this code and, although the execution didn't return errors in the IDE, the new metadata didn't appear in the items.

 

   from arcgis.gis import GIS
   from arcgis.gis import Item


   myGIS = GIS(myURL, myUSER)

   #READ 2-COLUMN .csv FILE. COL 1 = ITEM ID, COL2 = PATH TO INPUT ARCGIS METADATA FILE
   csv_file = open(the_csv, "r")
   csv_info = csv_file.readlines()
   csv_file.close()
   #LOOP FOR WORKING EACH METADATA FILE
   for i in csv_info:
      j = i.split(",")
      the_id = j[0]
      the_xml = j[1]
      myItem = Item(myGIS, the_id)
      myItem.update(item_properties = {},metadata = the_xml)
   #I ALSO TRIED THIS ALTERNATIVE AND WASN'T SUCCESSFUL:
   #myItem.metadata = the_xml
The API documentation isn't clear on how to do this. It doesn't give parameters for instantiating the Item class. Then, in the Item-class section, it suggests 2 ways to load metadata (myItem.update() and myItem.metadata).

Outcomes