[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 ___ Archivesspace_Users_Group mailing list Archivesspace_Users_Group@lyralists.lyrasis.org http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
Re: [Archivesspace_Users_Group] Updating containers via archival_object POST
Hi Don, What version of ASpace are you running? I’m guessing either 1.4.2 with container management plugin or 1.5+… If that is the case, then the problem is that the data you are trying to change in the snippet below isn’t actually controlled from within “container” anymore. You’ve actually got to look for & change the “sub_container” and/or the “top_containers” record linked to from “sub_container”: "instances": [ { "sub_container": { "indicator_2": "2", "type_2": "folder", "jsonmodel_type": "sub_container", "top_container": { "ref": "/repositories/3/top_containers/12063" } } } ] So, in the blob you provide below, type_1, indicator_1, and barcode_1 could be modified by POSTing to the linked top_container record, and type_2 and indicator_2 could be changed by POSTing the AO back with modifications to sub_container instead of container. Yes, it’s a pain. I’m spending the ocassional down moment working on a script to automate some of this for us here (GET record, dump into a csv, processing archivists make changes in csv, then it POSTs back to the proper records/subrecords), but it is no where ready for primetime yet, and won’t be for a while. Though, if anyone has this work already complete, I’m all ears! ☺ Lora From: archivesspace_users_group-boun...@lyralists.lyrasis.org [mailto:archivesspace_users_group-boun...@lyralists.lyrasis.org] On Behalf Of Donald Mennerich Sent: Monday, May 22, 2017 4:11 PM To: Archivesspace Users Group 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 ___ Archivesspace_Users_Group mailing list Archivesspace_Users_Group@lyralists.lyrasis.org http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
Re: [Archivesspace_Users_Group] Updating containers via archival_object POST
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-boun...@lyralists.lyrasis.org [mailto:archivesspace_users_group-boun...@lyralists.lyrasis.org] On Behalf Of Donald Mennerich Sent: Monday, May 22, 2017 4:11 PM To: Archivesspace Users Group 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 ___ Archivesspace_Users_Group mailing list Archivesspace_Users_Group@lyralists.lyrasis.org http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group