[Archivesspace_Users_Group] Error setting parent of Archival Object via API

James Bullen james at hudmol.com
Wed Aug 25 22:53:35 EDT 2021


Hi again Tommy,

It looks like this ends up at this line:
https://github.com/archivesspace/archivesspace/blob/master/backend/app/model/mixins/tree_nodes.rb#L63 <https://github.com/archivesspace/archivesspace/blob/master/backend/app/model/mixins/tree_nodes.rb#L63>

Where, if you give it a large value for position (ie more than the maximum number of siblings you would expect in your data) it will end up being the last in the list.

It wouldn’t be too much work for someone to honor the optional position declaration in the endpoint and trace it down to here where it would default to siblings_count - 1. That is, if you don’t specify a position it gets added to the end - seems like a reasonable default behavior.


Cheers,
James


> On Aug 25, 2021, at 2:02 AM, Keswick, Thomas (Tommy) <tkeswick at caltech.edu> wrote:
> 
> Thanks, James. Adding the position parameter does seem to work.
> 
> Does anyone know of a way to add an item to the end of the children list without having to count the number of existing children? Using -1 (negative one) does not work as “Offsets must be greater than or equal to 0”.
> 
> Cheers,
> Tommy
> 
>> On Aug 23, 2021, at 5:46 PM, James Bullen <james at hudmol.com <mailto:james at hudmol.com>> wrote:
>> 
>> 
>> Hi Tommy,
>> 
>> I’m ready to be wrong on this, but just had a quick look and it seems like the position param is required even though the endpoint declares it as optional.
>> 
>> 
>> Cheers,
>> James
>> 
>> 
>>> On Aug 24, 2021, at 9:30 AM, Keswick, Thomas (Tommy) <tkeswick at caltech.edu <mailto:tkeswick at caltech.edu>> wrote:
>>> 
>>> Greetings.
>>> 
>>> I’m trying to use the Set the parent/position of an Archival Object in a tree <https://archivesspace.github.io/archivesspace/api/#set-the-parent-position-of-an-archival-object-in-a-tree> API endpoint but I am getting an error when I supply both the archival object ID and the parent ID in what should be the correct way. The Archival Object is an item-level record and the parent is a series-level record, both under the same Resource.
>>> 
>>> The error is:
>>> {
>>>     "error": "comparison of Integer with nil failed"
>>> }
>>> 
>>> Here is some sample Python code that fails:
>>> ```
>>> import json
>>> 
>>> from asnake.client import ASnakeClient
>>> 
>>> asnake_client = ASnakeClient()
>>> asnake_client.authorize()
>>> 
>>> parent_post_response = asnake_client.post(
>>>     "/repositories/2/archival_objects/96413/parent?parent=96414"
>>> )
>>> print(json.dumps(parent_post_response.json(), sort_keys=True, indent=4))
>>> ```
>>> 
>>> The locally installed ArchivesSpace version that I am testing on is 2.8.1 currently.
>>> 
>>> Thanks for any help.
>>> 
>>> Cheers,
>>> Tommy
> 
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group

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


More information about the Archivesspace_Users_Group mailing list