[Archivesspace_api_doc_adhoc] find_by_id Endpoint Help

Mayo, Dave dave_mayo at harvard.edu
Wed May 25 20:47:32 EDT 2022


Hi Corey!

Sorry for taking so long to get back to you!

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.

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.

Here’s a working example for two records from Harvard:

x.client.get('repositories/3/find_by_id/resources', params={'identifier[]': ['["ecb00051",null,null,null]', '["bf-test"]']}).json()

This returns:

{'resources': [{'ref': '/repositories/3/resources/7303'},
  {'ref': '/repositories/3/resources/9611'}]}

So, a working version of your query would be:

find_res_id = client.get(‘repositories/2/find_by_id/resources’, params={‘identifier’: [‘[“test”, “1234”, “abcd”, “!@#$”]’]})

Or less hatefully? Maybe?

import json
find_res_id = client.get(‘repositories/2/find_by_id/resources’, params={‘identifier’: [json.dumps([‘test’, ‘1234’, ‘abcd’, ‘!@#$’])]})

In any event, it’s a weird way to do business and I don’t care for it.

--
Dave Mayo (he/him)
Senior Digital Library Software Engineer
Harvard University > HUIT > LTS

From: <archivesspace_api_doc_adhoc-bounces at lyralists.lyrasis.org> on behalf of Corey Schmidt <Corey.Schmidt at uga.edu>
Reply-To: "archivesspace_api_doc_adhoc at lyralists.lyrasis.org" <archivesspace_api_doc_adhoc at lyralists.lyrasis.org>
Date: Wednesday, March 23, 2022 at 4:23 PM
To: "archivesspace_api_doc_adhoc at lyralists.lyrasis.org" <archivesspace_api_doc_adhoc at lyralists.lyrasis.org>
Subject: [Archivesspace_api_doc_adhoc] find_by_id Endpoint Help

Dear all,

Hello, this is Corey Schmidt from the University of Georgia. I hope everyone is well and enjoying the slow warmup to Spring.

I've been hitting some roadblocks trying to write documentation for API endpoints and I wanted to askfor your help. For the find_by_id resource endpoint<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=>, 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:

from asnake.client import ASnakeClient
import asnake.logging as loggin

client = ASnakeClient(baseurl=as_api, username=as_un, password=as_pw)
client.authorize()

find_res_id = client.get('repositories/2/find_by_id/resources', params={'identifier[]': ['test', '1234', 'abcd', '!@#$']})
print(find_res_id.json(), find_res_id)

Here's the error message:
{'error': "Had some trouble parsing your request: unexpected token at 'test'"} <Response [400]>

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.

Any help/advice would be appreciated, thanks!

Corey


Corey Schmidt
Special Collections Libraries | ArchivesSpace Project Manager



706-542-8151<tel:7065428151> | Corey.Schmidt at uga.edu<mailto:Corey.Schmidt at uga.edu>


[University of Georgia]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_api_doc_adhoc/attachments/20220526/75ec3624/attachment-0001.html>


More information about the Archivesspace_api_doc_adhoc mailing list