<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<div dir="auto">One thing is that you probably want to do "${IDENTIFIER}" to avoid escaping issues. But the big thing is that requests actually does some negotiation around "array params" that you have to manually handle in shell - so instead of passing in
 identifier as one array of json arrays, you'd actually want to pass each identifier directly as one array.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Basically, you would pass each serialized (and URL encoded) json array of components to a separate "identifier[]=" param and repeat as necessary. </div>
<div><br>
</div>
<div id="ms-outlook-mobile-signature" dir="auto">Get <a href="https://aka.ms/AAb9ysg">
Outlook for Android</a></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_api_doc_adhoc-bounces@lyralists.lyrasis.org <archivesspace_api_doc_adhoc-bounces@lyralists.lyrasis.org> on behalf of Corey Schmidt
 <Corey.Schmidt@uga.edu><br>
<b>Sent:</b> Thursday, May 26, 2022 10:43:35 AM<br>
<b>To:</b> ArchivesSpace API Ad Hoc Working Group <archivesspace_api_doc_adhoc@lyralists.lyrasis.org><br>
<b>Subject:</b> Re: [Archivesspace_api_doc_adhoc] find_by_id Endpoint Help</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Consolas}
@font-face
        {font-family:Georgia}
@font-face
        {font-family:"Lucida Console"}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.x_MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New"}
span.x_HTMLPreformattedChar
        {font-family:Consolas}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
span.x_EmailStyle20
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_EmailStyle22
        {font-family:"Calibri",sans-serif;
        color:#1F497D}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="blue" vlink="purple">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="color:#1F497D">Hey Dave,<br>
<br>
That’s alright, I spoke with Tommy Keswick at Caltech and we got something working, but it’s a cumbersome workaround using urllib.parse.quote and lots of extra lines of code.<br>
<br>
That explains a lot why this was so frustrating! I’ve tried your examples and they work perfectly, thank you so so much!<br>
<br>
I wonder if I couldn’t pick your brain for helping me write the SHELL examples for this? So far, I’ve got something like so:<br>
<br>
</span><span style="font-size:9.0pt; font-family:"Lucida Console"">$ export IDENTIFIER=['["test","1234","abcd","5678"]']</span></p>
<p class="x_MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt; font-family:"Lucida Console"">$ curl -H -g "X-ArchivesSpace-Session: $SESSION" "http://our_aspace_api_url/repositories/2/find_by_id/resources?identifier[]=$IDENTIFIER"</span></p>
<p class="x_MsoNormal" style="text-autospace:none"><span style="color:#1F497D"><br>
The above gets a response from ASpace, but doesn’t return any results like in the python example.
<br>
<br>
</span><span style="font-size:9.0pt; font-family:"Lucida Console"">  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current</span></p>
<p class="x_MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt; font-family:"Lucida Console"">                                 Dload  Upload   Total   Spent    Left  Speed</span></p>
<p class="x_MsoNormal" style="text-autospace:none"><span style="font-size:9.0pt; font-family:"Lucida Console"">100    17  100    17    0     0    482      0 --:--:-- --:--:-- --:--:--   500{"resources":[]}</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"><br>
Can you spot anything wrong with how I’m making the call? I changed the fourth ID from !@#$ to 5678 since it was difficult for SHELL to accept those characters<br>
<br>
Corey</span></p>
<p class="x_MsoNormal"><span style="color:#1F497D"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b>From:</b> archivesspace_api_doc_adhoc-bounces@lyralists.lyrasis.org <archivesspace_api_doc_adhoc-bounces@lyralists.lyrasis.org>
<b>On Behalf Of </b>Mayo, Dave<br>
<b>Sent:</b> Wednesday, May 25, 2022 8:48 PM<br>
<b>To:</b> ArchivesSpace API Ad Hoc Working Group <archivesspace_api_doc_adhoc@lyralists.lyrasis.org><br>
<b>Subject:</b> Re: [Archivesspace_api_doc_adhoc] find_by_id Endpoint Help</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt; font-family:"Times New Roman",serif; color:#BA0C2F">[EXTERNAL SENDER - PROCEED CAUTIOUSLY]</span><span style="font-size:12.0pt; font-family:"Times New Roman",serif"></span></p>
<div>
<p class="x_MsoNormal">Hi Corey! </p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Sorry for taking so long to get back to you!</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">The reason you’ve had no success is that, frankly, this aspect of the app’s functionality is bad? Bad, it is poorly implemented in a way that makes it basically impossible to suss out without reading the code.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">What this function actually expects is: an array of strings with serialized JSON, each of which contains a JSON array of a four part id, null trailing components of which can be omitted.</p>
<div>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Here’s a working example for two records from Harvard:<br>
<br>
x.client.get('repositories/3/find_by_id/resources', params={'identifier[]': ['["ecb00051",null,null,null]', '["bf-test"]']}).json()<br>
<br>
This returns:<br>
<br>
{'resources': [{'ref': '/repositories/3/resources/7303'},</p>
<p class="x_MsoNormal">  {'ref': '/repositories/3/resources/9611'}]}<br>
<br>
So, a working version of your query would be:<br>
<br>
find_res_id = client.get(‘repositories/2/find_by_id/resources’, params={‘identifier’: [‘[“test”, “1234”, “abcd”, “!@#$”]’]})<br>
<br>
Or less hatefully? Maybe?<br>
<br>
import json<br>
find_res_id = client.get(‘repositories/2/find_by_id/resources’, params={‘identifier’: [json.dumps([‘test’, ‘1234’, ‘abcd’, ‘!@#$’])]})</p>
<p class="x_MsoNormal" style="margin-bottom:12.0pt"><br>
In any event, it’s a weird way to do business and I don’t care for it.</p>
<p class="x_MsoNormal">--</p>
<p class="x_MsoNormal">Dave Mayo (he/him)</p>
</div>
<p class="x_MsoNormal">Senior Digital Library Software Engineer<br>
Harvard University > HUIT > LTS</p>
<p class="x_MsoNormal"> </p>
<div style="border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b><span style="font-size:12.0pt; color:black">From: </span>
</b><span style="font-size:12.0pt; color:black"><<a href="mailto:archivesspace_api_doc_adhoc-bounces@lyralists.lyrasis.org">archivesspace_api_doc_adhoc-bounces@lyralists.lyrasis.org</a>> on behalf of Corey Schmidt <<a href="mailto:Corey.Schmidt@uga.edu">Corey.Schmidt@uga.edu</a>><br>
<b>Reply-To: </b>"<a href="mailto:archivesspace_api_doc_adhoc@lyralists.lyrasis.org">archivesspace_api_doc_adhoc@lyralists.lyrasis.org</a>" <<a href="mailto:archivesspace_api_doc_adhoc@lyralists.lyrasis.org">archivesspace_api_doc_adhoc@lyralists.lyrasis.org</a>><br>
<b>Date: </b>Wednesday, March 23, 2022 at 4:23 PM<br>
<b>To: </b>"<a href="mailto:archivesspace_api_doc_adhoc@lyralists.lyrasis.org">archivesspace_api_doc_adhoc@lyralists.lyrasis.org</a>" <<a href="mailto:archivesspace_api_doc_adhoc@lyralists.lyrasis.org">archivesspace_api_doc_adhoc@lyralists.lyrasis.org</a>><br>
<b>Subject: </b>[Archivesspace_api_doc_adhoc] find_by_id Endpoint Help</span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black">Dear all,</span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black"><br>
Hello, this is Corey Schmidt from the University of Georgia. I hope everyone is well and enjoying the slow warmup to Spring.<br>
<br>
I've been hitting some roadblocks trying to write documentation for API endpoints and I wanted to askfor your help. For the
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__archivesspace.github.io_archivesspace_api_-3Fshell-23find-2Dresources-2Dby-2Dtheir-2Didentifiers&d=DwMFAw&c=WO-RGvefibhHBZq3fL85hQ&r=_Mv1dY22K7jvT5MD7xjbvGVzRDOUMhx4WYcnPSIzYnE&m=C2RTpp6a036fpnD59EANxOYTWgp62F2fxW6SOcn7HPqjzSghIQN4KWW5_v9UYUJR&s=jI_tQ6Z_E7reBBJrWf2gLSIXIMZoFQN7jLH3NgzihxQ&e=" title="https://archivesspace.github.io/archivesspace/api/?shell#find-resources-by-their-identifiers">
find_by_id resource endpoint</a>, I'm trying to find a resource with a four-part ID, but when I call the endpoint, it keeps giving me an error I can't pin down. Here's what I'm calling:
</span></p>
<div>
<pre style="background:#2B2B2B"><span style="color:#CC7832">from </span><span style="color:#A9B7C6">asnake.client </span><span style="color:#CC7832">import </span><span style="color:#A9B7C6">ASnakeClient<br></span><span style="color:#CC7832">import </span><span style="color:#A9B7C6">asnake.logging </span><span style="color:#CC7832">as </span><span style="color:#A9B7C6">loggin</span></pre>
<pre style="background:#2B2B2B"><span style="color:#A9B7C6">client = ASnakeClient(</span><span style="color:#AA4926">baseurl</span><span style="color:#A9B7C6">=as_api</span><span style="color:#CC7832">, </span><span style="color:#AA4926">username</span><span style="color:#A9B7C6">=as_un</span><span style="color:#CC7832">, </span><span style="color:#AA4926">password</span><span style="color:#A9B7C6">=as_pw)<br>client.authorize()</span><span style="color:gray"><br><br></span><span style="color:#A9B7C6">find_res_id = client.get(</span><span style="color:#6A8759">'repositories/2/find_by_id/resources'</span><span style="color:#CC7832">, </span><span style="color:#AA4926">params</span><span style="color:#A9B7C6">={</span><span style="color:#6A8759">'identifier[]'</span><span style="color:#A9B7C6">: [</span><span style="color:#6A8759">'test'</span><span style="color:#CC7832">, </span><span style="color:#6A8759">'1234'</span><span style="color:#CC7832">, </span><span style="color:#6A8759">'abcd'</span><span style="color:#CC7832">, </span><span style="color:#6A8759">'!@#$'</span><span style="color:#A9B7C6">]})<br></span><span style="color:#8888C6">print</span><span style="color:#A9B7C6">(find_res_id.json()</span><span style="color:#CC7832">, </span><span style="color:#A9B7C6">find_res_id)</span></pre>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black">Here's the error message:</span></p>
</div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black">{'error': "Had some trouble parsing your request: unexpected token at 'test'"} <Response [400]><br>
<br>
It may be an issue with the requests package, but I'm not sure. I tested both ASnake and requests, and they gave the same error.<br>
<br>
Any help/advice would be appreciated, thanks!<br>
<br>
Corey</span></p>
<div>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div id="x_Signature">
<div>
<div>
<p style="background:white"><b><span style="font-size:9.0pt; font-family:"Georgia",serif; color:black">Corey Schmidt</span></b><span style="font-size:9.0pt; font-family:"Georgia",serif; color:black">
<br>
Special Collections Libraries | <i>ArchivesSpace Project Manager</i></span></p>
<p style="background:white"><span style="font-size:9.0pt; font-family:"Georgia",serif; color:black"> </span></p>
<p style="background:white"><span style="font-size:9.0pt; font-family:"Georgia",serif; color:black"><a href="tel:7065428151">706-542-8151</a> |
<a href="mailto:Corey.Schmidt@uga.edu">Corey.Schmidt@uga.edu</a></span></p>
<p style="background:white"><span style="font-size:9.0pt; font-family:"Georgia",serif; color:black"> </span></p>
<div>
<p class="x_MsoNormal" style="background:white"><span style="font-size:12.0pt; color:black"><img border="0" width="160" id="x__x0000_i1025" src="https://brand.uga.edu/email-signature-builder/assets/images/uga-logo@2x.png" alt="University of Georgia" style="width:1.6666in"></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>