Skip to main content
Solved

Optimistic Lock Failed

  • September 30, 2020
  • 3 replies
  • 46 views

Forum|alt.badge.img+6

We're working on a bit of an API project centered around building an app that would allow some of our lower-privileged users to update prestages for mobile devices using a tool that we provide. Using the new API, it looks like this should be possible, but, whenever we try to update the status of a device using an api call, we get an error 409: Optimistic Lock Failed . This happens even when we use the 'Try it' options through the API UI. This happens if we try to delete the scoping or modify it.

Here's the API call (with variables):

curl -X POST "$JSS_URL/api/v2/mobile-device-prestages/5/scope/delete-multiple" -H "accept: application/json" -H "Authorization: $token" -H "Content-Type: application/json" -d "{"serialNumbers":["$serial_number"],"versionLock":1}"

Here's the return:

{ "httpStatus" : 409, "errors" : [ { "code" : "OPTIMISTIC_LOCK_FAILED", "description" : "Conflict", "id" : "0", "field" : null } ]

Has anyone else seen this? Am I missing something? Is it something easy?

Best answer by SamF

The answer from this thread should also address the scenario you're describing. The value for the versionLock attribute included in your request body will need to match the current value of versionLock when performing a GET of that same resource (id 5 in your case).

3 replies

Forum|alt.badge.img+20
  • Employee
  • Answer
  • September 30, 2020

The answer from this thread should also address the scenario you're describing. The value for the versionLock attribute included in your request body will need to match the current value of versionLock when performing a GET of that same resource (id 5 in your case).


Forum|alt.badge.img+6
  • Author
  • New Contributor
  • September 30, 2020

That did the trick! Thank you!


Forum|alt.badge.img+2
  • New Contributor
  • March 13, 2021

Thanks Sam! I noticed the versionLock key in the examples but it isn't documented so I thought that was a static value referring to the version of the schema.