[Archivesspace_Users_Group] Update a Resource via the API

Corey Schmidt Corey.Schmidt at uga.edu
Wed Jul 22 11:54:56 EDT 2020

Dear all,

Hello, this is Corey Schmidt, ArchivesSpace Project Manager at the University of Georgia. I hope you all are doing well and staying cool!

I'm trying to update records via the API using the Update a Resource endpoint (https://archivesspace.github.io/archivesspace/api/#update-a-resource). I found Duke made a script (https://github.com/duke-libraries/archivesspace-duke-scripts/blob/master/python/asnake_update_all_resources_and_aos.py) 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 (https://github.com/archivesspace/archivesspace/blob/0c4cb2dd263bbeacdbce70567ccbb86634cde769/backend/app/controllers/resource.rb#L114).

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 <proceeds to quote entire json record>

The following is the code I'm running in python:

get_resource = client.get('/repositories/5/resources/1814')
resource = json.loads(get_resource.text)
resource["restrictions"] = True
update_resource = client.post('/repositories/5/resources/1814', json=json.dumps(resource))
# update_resource = client.post('/repositories/5/resources/1814', params={"id": 1814, "resource": json.dumps(resource), "repo_id": 5})
# the last line produces this error: <Response [400]> {"error":"Had some trouble parsing your request: A JSON text must at least contain two octets!"}
print(update_resource, update_resource.text)

I've attached the json file to this email.

Any help would be greatly appreciated. Thanks!


Corey Schmidt
ArchivesSpace Project Manager
University of Georgia Special Collections Libraries
Email: Corey.Schmidt at uga.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20200722/8fbc2c00/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resource.json
Type: application/json
Size: 15416 bytes
Desc: resource.json
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20200722/8fbc2c00/attachment.json>

More information about the Archivesspace_Users_Group mailing list