[Archivesspace_Users_Group] Updating containers via archival_object POST

Detelich, Alicia alicia.detelich at yale.edu
Tue May 23 09:44:14 EDT 2017


Hi Don,

Are you using Python to make the updates? Can you post what you have tried so far? Here’s an example of how to make an update to a single archival object instance via Python 3, which worked for me when I tested it this morning:

api_url = your api url…
repo_num = your repository number…

archival_object_json = requests.get(api_url+ ‘/repositories/repo_num/archival_objects/1987146’, headers=headers).json()

archival_object_json["instances"] = [{"container": {"barcode_1": '39002042614314', "container_locations": [{"jsonmodel_type": "container_location", "ref": '/locations/9', "start_date": "2015-06-02", "status": "current"}], "indicator_1": '2', "type_1": "box"}, "instance_type": "mixed_materials", "jsonmodel_type": "instance", "sub_container": {"jsonmodel_type": "sub_container", "top_container": {"ref": '/repositories/repo_num/top_containers/190797'}}}]

archival_object_data = json.dumps(archival_object_json)

archival_object_update = requests.post(api_url+‘/repositories/repo_num/archival_objects/1987146’, headers=headers, data=archival_object_data).json()


If you are trying to do something like archival_object_json[‘container’] I don’t think it will work, unless maybe you do archival_object_json[‘instances’][‘container’] – but I didn’t check on that.

Also, be sure that all data elements you are updating are correct and consistent – I tried to make a test update using fake container info and it did not work, but when I tried updating the instance with data from an existing top container everything went through just fine. I just changed the barcode, top container ref, indicator, and location to reflect the data from the other container, and it updated. Hope this helps.

P.S. I have a script which makes these kinds of updates in batch by pulling the info you wish to update from a CSV. I can clean it up a bit and share if anyone is interested…

Alicia Detelich
Archivist
Manuscripts and Archives
Yale University Libraries

From: archivesspace_users_group-bounces at lyralists.lyrasis.org [mailto:archivesspace_users_group-bounces at lyralists.lyrasis.org] On Behalf Of Donald Mennerich
Sent: Monday, May 22, 2017 4:11 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: [Archivesspace_Users_Group] Updating containers via archival_object POST

Hello List,
I'm working a data remediation problem via the aspace API I can't seem to get any of the values in a container key within an archival_object to update when I post. For example, within a json object of type archival_object like:

"container": {
    "type_1": "box",
    "indicator_1": "1",
    "barcode_1": "31142054615128",
    "type_2": "folder",
    "indicator_2": "14",
    "container_locations": [],
    "lock_version": 25
}
If I change any of the values and POST, none of the updates seem to persist. This doesn't generate an errors, and any changes to the record otherwise seems to save. I'm wondering if this is just not possible, and if so, is there another endpoint that might be used to update container information?

Thanks, Don

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20170523/f494696b/attachment.html>


More information about the Archivesspace_Users_Group mailing list