I’m building an app for managing my keypad codes across a number of locks. I have a situation where I have run a DELETE request which has successfully deleted the entries on the lock. However, a GET auths request to the web API still returns the deleted entries. I have tried performing a manual sync, which the web API claims to have completed successfully, but the list of auths is still out of sync.
However, I can make a POST update to an entry that exists both on the web and on the smartlock and it is reflected in both places immediately.
I assume you received a 200 OK response for the DELETE request.
This is possible, because the Web API is asynchronous. When you send a command you will get an immediate OK response (i.e. 200). Once the server has received the API call, it will try to reach the Smart Lock and change/delete the code (all the codes are stored on the Smart Lock itself). This usually takes some seconds. If the connection to the Smart Lock is broken or unstable it might not work at all and you get unreliable results.
And in your case, clearly the auths were not deleted as you checked again.
Could you please log the server state of the Smart Lock, and if it is online during all these operations? If yes, then please check if the auth ID is changing for some reason, and thus not deleted.
Yes, but 18 hours later the lock and the web API are still out of sync. I manually added an entry to the lock, synced, and it immediately showed up in the web API. But if I try (using the Nuki Web interface) deleting one of the entries that exist only in the web API then I get an error (“Deleting authorization failed”).
I’m not sure where to log the server state - I don’t see any config entries for that? But I was getting a number of bad gateway responses yesterday while working on my app, which may indicate that there were issues. I don’t see the auth IDs changing at all.
But regardless of the issue that this could happen again in the future, how can I get rid of these phantom entries now?
If the auths are still exisiting, then you must perform the DELETE request again and check if auths are deleted, and you are doing that exactly.
Deleting authorization failed message occurs when the smart lock is offline. Try to update the smart lock and check if it is online. You can check it via Nuki Web interface or via the API for a Smart lock (serverState should be ‘0’). The only way to get rid of these auths is to ensure smart lock is connected, synced, and then auths are deleted.
The server state is 0. The auths don’t exist on the smartlock, just in the web API. If I try to delete the auth via the web API (or via Nuki Web) it accepts the request and then later reports failure (obviously, because the auth doesn’t exist on the lock). Other changes made directly to the lock via the app quickly show up in the web API. The smartlock has been in this state for at least 48 hours.
Kindly request you to remove the smartlockId from the forum as the forum is meant for generic developer queries. For all support requests, please create a ticket on Support Channel to report issues. In this case, you can provide more details over a DM. Thanks.
After talking to support, the only thing that worked was for me to delete the lock from Nuki Web and then readd it. This worked, but it is a workaround for a bug in Nuki’s sync API.
I hope this will be resolved in the not too distant future otherwise it is impossible for the user to know the true state of auths on the smartlock solely from the web API.