Optimistic Lock Failed

curtis_bohlmeye
New Contributor

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?

1 ACCEPTED SOLUTION

SamF
Contributor II
Contributor II

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).

View solution in original post

3 REPLIES 3

SamF
Contributor II
Contributor II

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).

curtis_bohlmeye
New Contributor

That did the trick! Thank you!

gregsheppard
New Contributor II

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.