<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Karen,<div><br></div><div>I think you're getting the error because it's looking to set those values on a file version that already exists, and the file version doesn't exist yet.</div><div><br></div><div>I have a script that does something similar and what I've done is create a definition for a new file version, and then done an "append" on the record in question (record being the digital object).</div><div><br></div><div><div>def add_thumbnail(thumbnail_uri):</div><div>    note_dict =  {'file_uri': thumbnail_uri,</div><div>    'publish': True, #change to False if you do not want the file version to be published.</div><div>    'xlink_actuate_attribute': 'onLoad',</div><div>    'xlink_show_attribute': 'embed',</div><div>    'use_statement': 'image-thumbnail',</div><div>    'jsonmodel_type': 'file_version'</div><div>    }</div></div><div><br></div><div><br></div><div>Later I have record['file_versions'].append(add_thumbnail)</div><div><br></div><div>thumbnail_uri is coming from a spreadsheet. If seeing the full script is helpful for you please let me know and I'd be happy to share it with you.</div><div><br></div><div>Best,</div><div>Michelle</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 18, 2020 at 12:48 PM Karen Miller <<a href="mailto:k-miller3@northwestern.edu" target="_blank">k-miller3@northwestern.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">I hope there are still some folks around to think about an API problem I’m having!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">We’re updating URLs in our digital objects. I can easily update the URL that exists in digital objects, using Python syntax like this:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['file_versions'][0]['file_uri'] = permalink<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">post_record = <a href="http://requests.post" target="_blank">requests.post</a>(f"{api_url}/{digital_object_uri}", headers=headers, json=digital_object_json).json()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">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:
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['file_versions'][1]['file_uri'] = thumbnail<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][0]['content'] = note1<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][0]['jsonmodel_type'] = 'note_digital_object'<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][0]['publish'] = False<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][0]['type'] = 'note'                               
<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][1]['content'] = note2<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][1]['jsonmodel_type'] = 'note_digital_object'<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][1]['publish'] = False<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">digital_object_json['notes'][1]['type'] = 'note'<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">where “thumbnail”, “note1”, and “note2” are values from the spreadsheet. However, I’m getting this error for each of these statements:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-indent:0.5in"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">IndexError: list index out of range<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">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!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">Best regard and happy holidays,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)">Karen<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-family:Arial,sans-serif;color:rgb(39,35,35)">Karen D. Miller<u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:black">Monographic Cataloger/Metadata Specialist<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:rgb(39,35,35)">Northwestern University Libraries<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:rgb(78,42,133)">Northwestern University<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:black">1970 Campus Drive<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:black">Evanston, IL 60208<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:rgb(39,35,35)"><a href="http://www.library.northwestern.edu" target="_blank">www.library.northwestern.edu</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:black"><a href="mailto:k-miller3@northwestern.edu" target="_blank">k-miller3@northwestern.edu</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Arial,sans-serif;color:rgb(39,35,35)">874.467.3462</span><span style="color:rgb(31,73,125)"><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

_______________________________________________<br>
Archivesspace_Users_Group mailing list<br>
<a href="mailto:Archivesspace_Users_Group@lyralists.lyrasis.org" target="_blank">Archivesspace_Users_Group@lyralists.lyrasis.org</a><br>
<a href="http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group" rel="noreferrer" target="_blank">http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="tahoma, sans-serif">Michelle Paquette</font></div><div dir="ltr"><font face="tahoma, sans-serif">(she/her)<br></font><div><font face="tahoma, sans-serif">Metadata & Technical Services Archivist</font></div><div><font face="tahoma, sans-serif">Special Collections</font></div><div><font face="tahoma, sans-serif">Smith College</font></div><div><font face="tahoma, sans-serif">413-585-7029</font></div><div><font face="tahoma, sans-serif"><a href="mailto:mpaquette@smith.edu" target="_blank">mpaquette@smith.edu</a></font></div><div><br></div><div><span style="color:rgb(34,34,34)"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap">Please note: In light of COVID-19, the Libraries are offering contactless pickup, and all other services will continue to be offered remotely. Visit </span><a href="http://bit.ly/SCLcovid-19" style="color:rgb(17,85,204)" target="_blank"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">bit.ly/SCLcovid-19</span></a><span style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap"> for full details.</span></p><br><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Please send any questions you may have to </span><a href="mailto:libraryhelp@smith.edu" style="color:rgb(17,85,204)" target="_blank"><span style="font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">libraryhelp@smith.edu</span></a><span style="font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">and they will be answered as soon as possible. Special Collections</span><span style="font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><a href="mailto:specialcollections@smith.edu" style="color:rgb(17,85,204)" target="_blank"><span style="font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">reference service</span></a><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> is active, but limited. For information about Smith College’s response to Covid-19, please visit the</span><a href="https://www.smith.edu/student-life/health-wellness/coronavirus" style="color:rgb(17,85,204)" target="_blank"><span style="font-family:Arial;color:rgb(34,34,34);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">college’s official website</span></a><span style="font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.</span><span style="font-family:Arial;background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span></span><span style="color:rgb(34,34,34)"> </span><br></div></div></div></div></div></div></div></div></div></div></div></div>