<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
That did it. Thanks!<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> archivesspace_users_group-bounces@lyralists.lyrasis.org <archivesspace_users_group-bounces@lyralists.lyrasis.org> on behalf of Kennedy, Nancy
<KennedyN@si.edu><br>
<b>Sent:</b> Wednesday, July 22, 2020 12:25 PM<br>
<b>To:</b> Archivesspace Users Group <archivesspace_users_group@lyralists.lyrasis.org><br>
<b>Subject:</b> Re: [Archivesspace_Users_Group] Update a Resource via the API</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr"><font color="BA0C2F">[EXTERNAL SENDER - PROCEED CAUTIOUSLY]</font><br>
<br>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi Corey - </div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
When you post your changes back, t<span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">ry this:</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<pre style="background-color:rgb(43,43,43); color:rgb(169,183,198); font-family:"JetBrains Mono",monospace; font-size:9.8pt">client.post(<span style="margin:0px; color:rgb(106,135,89)">'/repositories/5/resources/1814'</span><span style="margin:0px; color:rgb(204,120,50)">, </span><span style="margin:0px; color:rgb(170,73,38)">json</span>=resource)</pre>
<br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="x_Signature">
<div>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">Nancy Kennedy</div>
<div style="font-family:Tahoma; font-size:13px">Smithsonian Institution</div>
<div style="font-family:Tahoma; font-size:13px"><br>
</div>
<div style="font-family:Tahoma; font-size:13px"></div>
</div>
</div>
</div>
</div>
</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> archivesspace_users_group-bounces@lyralists.lyrasis.org <archivesspace_users_group-bounces@lyralists.lyrasis.org> on behalf of Corey Schmidt
<Corey.Schmidt@uga.edu><br>
<b>Sent:</b> Wednesday, July 22, 2020 11:54 AM<br>
<b>To:</b> archivesspace_users_group@lyralists.lyrasis.org <archivesspace_users_group@lyralists.lyrasis.org><br>
<b>Subject:</b> [Archivesspace_Users_Group] Update a Resource via the API</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<p class="x_x_MsoNormal" style="line-height:12.0pt; background:#FFEB9C"><b><span style="font-size:9.0pt; font-family:"Calibri",sans-serif; color:#9C6500">External Email - Exercise Caution</span></b></p>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Dear all,<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
Hello, this is Corey Schmidt, ArchivesSpace Project Manager at the University of Georgia. I hope you all are doing well and staying cool!<br>
<br>
<span>I'm trying to update records via the API using the Update a Resource endpoint (<a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchivesspace.github.io%2Farchivesspace%2Fapi%2F%23update-a-resource&data=02%7C01%7CKennedyN%40si.edu%7C6c3a9025238e436ebeee08d82e579a60%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C637310301090865378&sdata=JAmmPBNTMiJzK8RdmtK0aIiRPoaqEaEAU1gHBbkQ4yA%3D&reserved=0" originalsrc="https://archivesspace.github.io/archivesspace/api/#update-a-resource" shash="Eri1GZACjXgybO0J5fU0h0jLqiXmEktxRoq+zz39PEG/DPecy3iRFhz/jiFV6vmyiYaYVPwr95+6yh0H5uOnimlRLYQl3MF1SlZlSVcXyTYTK1w9Shwuuh/KuYbTIOOCWAqy1VuPvPpQrd6yIvKcAwKIwl5XO3la7CnofkjWwEc=">https://archivesspace.github.io/archivesspace/api/#update-a-resource</a>).</span>
I found Duke made a script (<a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fduke-libraries%2Farchivesspace-duke-scripts%2Fblob%2Fmaster%2Fpython%2Fasnake_update_all_resources_and_aos.py&data=02%7C01%7CKennedyN%40si.edu%7C6c3a9025238e436ebeee08d82e579a60%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C637310301090865378&sdata=ifr0tDYpc%2FjvBG2WGoiX8uedouLfZ5rGiyfUwLoVhUA%3D&reserved=0" originalsrc="https://github.com/duke-libraries/archivesspace-duke-scripts/blob/master/python/asnake_update_all_resources_and_aos.py" shash="qE/tvhONjeVJMGVkcophfio4/DX0xx5vpJfag08ZO0tHnbcTz53hgfuT6O4quQCcTvRB66Da46Zv8k0DrJdpJGzCIHW42F2OVD2Q8JlWNJmjw3qdubZjfdJ5kjrwQ/WBFWJ9uA1/hMkFviwrlO3oEBtajrnWM15ERMycVmWzXnY=">https://github.com/duke-libraries/archivesspace-duke-scripts/blob/master/python/asnake_update_all_resources_and_aos.py</a>)
to do this very thing and I modeled my request on that example. I also found what I think is the code for the endpoint, found in backend/app/controllers/resource.rb file, line 114 (<a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Farchivesspace%2Farchivesspace%2Fblob%2F0c4cb2dd263bbeacdbce70567ccbb86634cde769%2Fbackend%2Fapp%2Fcontrollers%2Fresource.rb%23L114&data=02%7C01%7CKennedyN%40si.edu%7C6c3a9025238e436ebeee08d82e579a60%7C989b5e2a14e44efe93b78cdd5fc5d11c%7C0%7C0%7C637310301090875376&sdata=WIMDFpICFKWlUmxIrsTRQnZZtnP3s2dV9JHR5RgVU1k%3D&reserved=0" originalsrc="https://github.com/archivesspace/archivesspace/blob/0c4cb2dd263bbeacdbce70567ccbb86634cde769/backend/app/controllers/resource.rb#L114" shash="bvSIZUYMKqflC3+aSXpdSse85ojIqP1ilYN3xjV6XcWs4cjlQhCsHfuXviiuBmy1AiuDOhBQCZ/qp/qO8De5fpJ23qCt8/vKHGtPUOc/nUuRBfFF0qYWWyMebR+SR/VoAO8CLhbJ8KY9ac13j1/Np9nvps9V0iLUoosHT1DIjRo=">https://github.com/archivesspace/archivesspace/blob/0c4cb2dd263bbeacdbce70567ccbb86634cde769/backend/app/controllers/resource.rb#L114</a>).<br>
<br>
<div>However, no matter the combinations I try for the request, I'm getting a <Response [400]> error with the following message: "error":"Had some trouble parsing your request: unexpected token at <<i>proceeds to quote entire json record</i>><br>
</div>
<div><br>
The following is the code I'm running in python:<br>
</div>
<div><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)"></span></div>
<pre style="background-color:rgb(43,43,43); color:rgb(169,183,198); font-family:"JetBrains Mono",monospace; font-size:9.8pt">get_resource = client.get(<span style="color:rgb(106,135,89)">'/repositories/5/resources/1814'</span>)<br><span style="color:rgb(136,136,198)">print</span>(get_resource.text)<br>resource = json.loads(get_resource.text)<br>resource[<span style="color:rgb(106,135,89)">"restrictions"</span>] = <span style="color:rgb(204,120,50)">True<br></span><span style="color:rgb(136,136,198)">print</span>(json.dumps(resource))<br>update_resource = client.post(<span style="color:rgb(106,135,89)">'/repositories/5/resources/1814'</span><span style="color:rgb(204,120,50)">, </span><span style="color:rgb(170,73,38)">json</span>=json.dumps(resource))<br><span style="color:rgb(128,128,128)"># update_resource = client.post('/repositories/5/resources/1814', params={"id": 1814, "resource": json.dumps(resource), </span><span style="color:rgb(128,128,128)">"repo_id": 5})<br># the last line produces this error: <Response [400]> {"error":"Had some trouble parsing your request: A JSON text must at least contain two octets!"}<br></span><span style="color:rgb(136,136,198)">print</span>(update_resource<span style="color:rgb(204,120,50)">, </span>update_resource.text)</pre>
<div><span style="font-family:calibri,arial,helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)"></span><br>
I've attached the json file to this email.<br>
<br>
Any help would be greatly appreciated. Thanks!<br>
<br>
Sincerely,<br>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="x_x_Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:Verdana,Geneva,sans-serif; color:rgb(0,0,0)">Corey Schmidt</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:Verdana,Geneva,sans-serif; font-size:11pt; color:rgb(51,51,51)">ArchivesSpace Project Manager</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:Verdana,Geneva,sans-serif; font-size:11pt; color:rgb(51,51,51)">University of Georgia Special Collections Libraries</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:Verdana,Geneva,sans-serif; font-size:10pt; color:rgb(102,102,102)"><i>Email:</i></span><span style="font-family:Verdana,Geneva,sans-serif; font-size:10pt; color:rgb(102,102,102)"> Corey.Schmidt@uga.edu</span><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>