I hope there are still some folks around to think about an API problem I'm 
having!

We're updating URLs in our digital objects. I can easily update the URL that 
exists in digital objects, using Python syntax like this:

digital_object_json['file_versions'][0]['file_uri'] = permalink

post_record = requests.post(f"{api_url}/{digital_object_uri}", headers=headers, 
json=digital_object_json).json()

where "permalink" is a value I've read in from a spreadsheet. This works just 
fine for me. But I wanted to get fancy and add a second URL as a thumbnail (I 
can do this through the staff interface and it works the way I anticipate) as 
well as a couple of notes. I thought that the syntax would be straightforward:

digital_object_json['file_versions'][1]['file_uri'] = thumbnail
digital_object_json['notes'][0]['content'] = note1
digital_object_json['notes'][0]['jsonmodel_type'] = 'note_digital_object'
digital_object_json['notes'][0]['publish'] = False
digital_object_json['notes'][0]['type'] = 'note'
digital_object_json['notes'][1]['content'] = note2
digital_object_json['notes'][1]['jsonmodel_type'] = 'note_digital_object'
digital_object_json['notes'][1]['publish'] = False
digital_object_json['notes'][1]['type'] = 'note'
where "thumbnail", "note1", and "note2" are values from the spreadsheet. 
However, I'm getting this error for each of these statements:

IndexError: list index out of range

because those aren't already in the JSON that I've retrieved. How do I add to 
the JSON? I'm not experienced enough with JSON or with Python and am looking 
for some basic help. Any advice will be appreciated!

Best regard and happy holidays,
Karen


Karen D. Miller
Monographic Cataloger/Metadata Specialist
Northwestern University Libraries
Northwestern University
1970 Campus Drive
Evanston, IL 60208
www.library.northwestern.edu
k-mill...@northwestern.edu
874.467.3462

_______________________________________________
Archivesspace_Users_Group mailing list
Archivesspace_Users_Group@lyralists.lyrasis.org
http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

Reply via email to