[Archivesspace_Users_Group] Error updating resource records through API

Mayo, Dave dave_mayo at harvard.edu
Fri Apr 17 10:36:46 EDT 2020


So, ArchivesSpace keeps track of whether it’s safe to modify an object via a field called “lock_version”. Any change to an object will increment this value, and this is probably what’s catching you up – something is altering the value between when you download the resource and when you update it.

There’s two things you can do.

- you can change the script you you fetch the JSON right before modifying and uploading it.
- you can delete lock_version from the object

The second carries risks, because if it’s failing because something else has modified the object in question, those changes can be lost.

--
Dave Mayo (he/him)
Senior Digital Library Software Engineer
Harvard University > HUIT > LTS

From: <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of "Huebschen, Alan M" <ahueb2 at uis.edu>
Reply-To: Archivesspace Users Group <Archivesspace_Users_Group at lyralists.lyrasis.org>
Date: Friday, April 17, 2020 at 10:26 AM
To: Archivesspace Users Group <Archivesspace_Users_Group at lyralists.lyrasis.org>
Subject: [Archivesspace_Users_Group] Error updating resource records through API

Hi all,

I’ve been attempting to update existing resource records through the API, the records already exist and I’m trying to upload modified versions of the JSON but I’m getting an error in response.

'error': 'The record you tried to update has been modified since you fetched it.'

At first I thought this meant either user_mtime, system_mtime, or create_time were preventing uploading an older version of the file but the error persists after replacing all time stamps with the current date and time.

Does anyone know what this error means?

Using ASnake:

resources = glob.glob('./resources/modified/' + '*.json')

    for file in resources:
        resources_id = file.rstrip('.json')
        resources_id = re.findall('\d+', resources_id)
        resource = json.load(open(file))
        response = client.post('repositories/2/resources/' + resources_id[0], json=resource).json()

        if response.get('error') != None:
            print("*")
            print(resources_id[0])
            print(response['error'])
            print(file)
            print("*")

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20200417/8c5ab7f9/attachment.html>


More information about the Archivesspace_Users_Group mailing list