[Archivesspace_Users_Group] Error updating resource records through API

James Bullen james at hudmol.com
Fri Apr 17 19:49:26 EDT 2020


You can just send back the lock_version you got with the get. No need to bump it - that happens on a successful update. The response to the update will include the new lock_version, like this:

{
  "status": "Updated",
  "id": 2,
  "lock_version": 23,
  "stale": NULL,
  "uri": "/repositories/2",
  "warnings": []
}

This is implemented via a sequel plugin:
https://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/OptimisticLocking.html



> On Apr 18, 2020, at 12:53 AM, Peter Heiner <ph448 at cam.ac.uk> wrote:
> 
> Huebschen, Alan M wrote on 2020-04-17 14:26:24:
>> 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.'
> 
> To update a record, you first need to fetch it to get its lock_version.
> The API will only allow updates to a resource with a lock_version
> greater than the one stored in the database, so you'll need to post your
> data including lock_version+1.
> 
> Hope that helps,
> p
> _______________________________________________
> Archivesspace_Users_Group mailing list
> Archivesspace_Users_Group at lyralists.lyrasis.org
> http://lyralists.lyrasis.org/mailman/listinfo/archivesspace_users_group
> 
> !DSPAM:5e99c2e335501411550710!

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


More information about the Archivesspace_Users_Group mailing list