[Archivesspace_Users_Group] Example of programmatically updating /agents/people via REST?

Doiel, Robert rsdoiel at caltech.edu
Wed Apr 20 14:10:25 EDT 2016


Hello Mark,

When I wrote my migration tool the biggest problem with /agents/people turned out to be the lock_version fields. If they are not correctly set (the value from the previous read) then the whole thing is rejected.  I can’t show you this in Python or Ruby as the tools I wrote are in Go and JavaScript but I am pretty sure you might be able to get an idea from them.  The tools here at Caltech can be seen at https://github.com/caltechlibrary/cait. The place to start would be the JavaScript example fix-agents-peoples.js.  The JavaScript uses the underlying Go code to get a JSON blob representing a person then updates the agents name fields and writes it back.

Sorting out the model structure I found using Stephen Dolan’s jq to be vary helpful. I would curl the request to get the agent I wanted to update. Tweak the resulting JSON, check it with jq, then send it back via curl.

I found the following very helpful too

+ https://www.youtube.com/watch?v=z0HR46q4F8o - A screen cast of using the API via curl
+ http://archivesspace.github.io/archivesspace/api/ which is a JavaScript generate page that shows the models (it’s not the page that lists in Googling “ArchivesSpace REST API”)

All the best,

Robert
(P.S. This week’s a bit busy but I’ll see if I can whip up a Python demo showing what you ask too)
-- 
R. S. Doiel, <rsdoiel at caltech.edu>

Digital Library Development
Caltech Library






On 4/20/16, 10:45 AM, "archivesspace_users_group-bounces at lyralists.lyrasis.org on behalf of Mark Cyzyk" <archivesspace_users_group-bounces at lyralists.lyrasis.org on behalf of mcyzyk at jhu.edu> wrote:

>Greetings!
>
>Does anyone have a really good and clear example of how to update 
>/agents/people via the REST API?  If so, I would love to see it.
>
>We've extracted a chunk of JSON using the API, have modified parts of 
>it, and now want to push it back in.
>
>It's looking like, in order to do this, the pseudo-code would be 
>something like:
>
>Read edited JSON file
>Parse JSON
>Start a session with the ASpace server
>Begin loop over parsed JSON
>      Post each /agent/people item individually using its ID
>End loop
>Spin in chair
>
>
>That's what I'm working on now (but would love to see a working example 
>[in Ruby or Python, preferably]).
>
>Best regards,
>
>Mark
>
>-- 
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
>Mark Cyzyk, M.A., M.L.S.
>Scholarly Communication Architect
>User Interface Applications Group
>The Sheridan Libraries
>The Johns Hopkins University
>mcyzyk at jhu.edu
>
>_______________________________________________
>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