[Archivesspace_Users_Group] Search Across Repositories and Get EAD XML - ArchivesSpace API

Corey Schmidt Corey.Schmidt at uga.edu
Tue Mar 10 08:28:56 EDT 2020


This is all great! I've adjusted my search query to use parameters you recommended and I'm getting a response back. Though my searches are not generating any results. I've tried searching for collection titles and random words, but nothing comes back in the results value. Would you have any recommendations?

client.get('search/repositories', params={"q": "Freeman collection", "page": 1, "type": ['resource']})

I've also adjusted my EAD xml endpoint call and saving the file as you recommended and it's working like a charm. It's interesting to note that in previous exports, the barcodes to containers were being attached to the "label" attribute for the container tag (label="Mixed Materials [5168852364844]"). Yet, these exports are generating the "physloc" element with the barcode as the value. This works for us, I just thought it was odd.

-----Original Message-----
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> On Behalf Of Mayo, Dave
Sent: Monday, March 9, 2020 12:46 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] Search Across Repositories and Get EAD XML - ArchivesSpace API

[EXTERNAL SENDER - PROCEED CAUTIOUSLY]


Oh, I missed the second part:

So, that endpoint returns the XML directly as the body of the response in memory.  The JSONDecodeError you’re getting is due to trying to decode this body as JSON, when what you actually have is XML!

If you want to save it to the filesystem, you just need to write it out:

response = client.get('repositories/5/resource_descriptions/5734.xml?include_unpublished=false&include_daos=true&numbered_cs=true&print_pdf=false&ead3=false')
with open('myfile.xml', 'wb') as f:
    file.write(response.content)

Keep in mind also the parameter-passing stuff from my other email, so the request there can be written as:

client.get('repositories/5/resource_descriptions/5734.xml', params={'include_unpublished': False, 'include_daos': True, 'numbered_cs': True, 'print_pdf': False, 'ead3': False})

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

From: <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Corey Schmidt <Corey.Schmidt at uga.edu>
Reply-To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Date: Monday, March 9, 2020 at 10:39 AM
To: "archivesspace_users_group at lyralists.lyrasis.org" <archivesspace_users_group at lyralists.lyrasis.org>
Subject: [Archivesspace_Users_Group] Search Across Repositories and Get EAD XML - ArchivesSpace API

Dear ArchivesSpace Members,

Hello, my name is Corey Schmidt and I’m working as the ArchivesSpace Project Manager at the University of Georgia. I hope you all are doing well and having a good start to your week.

I have two questions about how to utilize the ArchivesSpace API. First, I want to use the https://urldefense.proofpoint.com/v2/url?u=https-3A__archivesspace.github.io_archivesspace_api_-23search-2Dacross-2Drepositories&d=DwMFAg&c=WO-RGvefibhHBZq3fL85hQ&r=_Mv1dY22K7jvT5MD7xjbvGVzRDOUMhx4WYcnPSIzYnE&m=B2y_0wn1HLyXldJyck05IgPrsrOCn8LyjRI8q5uSbtc&s=_eqqK2s6KdcWsYV9Ke0loG2mitQ-I_nV-F9VeT24-l0&e= API endpoint searching with the resource identifier and take the results to get the URI for that resource. How do I structure my call to the API using the ASnake client (in python)? I have tried the following code with response 400 returned:

     client.get('search/repositories?type="resource"&q=ms954&all_ids=true')
     client.get('/search/repositories?q=ms954&type="resource"&all_ids=true')

Second, I want to download an EAD xml file directly from the API using this endpoint: https://urldefense.proofpoint.com/v2/url?u=https-3A__archivesspace.github.io_archivesspace_api_-23get-2Dan-2Dead-2Drepresentation-2Dof-2Da-2Dresource&d=DwMFAg&c=WO-RGvefibhHBZq3fL85hQ&r=_Mv1dY22K7jvT5MD7xjbvGVzRDOUMhx4WYcnPSIzYnE&m=B2y_0wn1HLyXldJyck05IgPrsrOCn8LyjRI8q5uSbtc&s=xwd2j6qv-zYs8pDbLpLM23dcSeDYcPUkZSAuio8FEVQ&e= XML. How do I specify where the EAD xml file saves to? I’m not even sure if it is saving anywhere on my computer. However, my requests are successful, generating a 200 response. I tried turning the response into json (using ASnake’s .json()) and writing it, but I keep getting a JSONDecodeError. This is my request:

     request_ead = client.get('repositories/5/resource_descriptions/5734.xml?include_unpublished=false&include_daos=true&numbered_cs=true&print_pdf=false&ead3=false')

Any help would be greatly appreciated!

Sincerely,

Corey

Corey Schmidt
ArchivesSpace Project Manager | University of Georgia Libraries
Email: mailto:Corey.Schmidt at uga.edu
Phone: +1-706-542-8151


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


More information about the Archivesspace_Users_Group mailing list