BUG in smartlock/auth allowedFromDate?

Sending a PIN to a keypad/smartlock via curl using

https://api.nuki.io/smartlock/180518XXXXX/auth

only works if you discard the allowedFromDate (and allowedUntilDate) values. If you add something like

“allowedFromDate”:“2022-12-20T10:42:00.000Z”

into your -d list of parameters, the request fails with some mystic response:

{“code”:422,“description”:“The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions”,“homeRef”:"/",“reasonPhrase”:“Unprocessable Entity”,“uri”:“HTTP Extensions for Distributed Authoring -- WEBDAV”}

This happens no matter which parameters you add: until, timeFrom or timeUntil, with or without weekdays.

Anyone knows the right format of the date? All I tried so far failed.

Tnx, Thore

No idea. anybody?

The date format seems correct. Are you updating the PIN or also the time?

Thanks for coming back on this, @poonam.chavan - It’s not an update, its an insert (or put, if you want). That’s what I am sending:

curl https://api.nuki.io/smartlock/180518XXXXX/auth -X PUT -H “Content-Type: application/json” -H “Accept: application/json” -H “Authorization: Bearer XXXXXXXXXXXXX” -d “{ “name”: “GeorgeLukas6”, “allowedFromDate”:“2022-12-22T11:42:00.000Z”, “allowedFromTime”: 0, “allowedUntilDate”: “2022-12-24T10:42:00.000Z”, “allowedUntilTime”: 0, “allowedWeekDays”:127, “remoteAllowed”: true, “type”: 13, “code”: 181821 }”

The message I get back is:

{“code”:422,“description”:“The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions”,“homeRef”:"/",“reasonPhrase”:“Unprocessable Entity”,“uri”:“HTTP Extensions for Distributed Authoring -- WEBDAV”}

Hi Thore,

We tried it on Swagger with your same command and it works, so pretty sure the format is right. Could you please try it on Swagger to check it?

Additionally, you could use the below format (in the same sequence) to check:

{
“name”: “example”,
“allowedFromDate”: “2022-12-21T14:44:04.764Z”,
“allowedUntilDate”: “2022-12-21T15:44:04.764Z”,
“allowedWeekDays”: 127,
“allowedFromTime”: 0,
“allowedUntilTime”: 0,
“accountUserId”: 0,
“enabled”: true,
“remoteAllowed”: true,
“code”: 112233
}

Hey @poonam.chavan ,

thanks for your reply.

it works when I try the same values with swagger. BUT: it also works with curl when I leave the dates out of my curl command. In this case I can insert a key. The difference is the date.

Trying your changes (accountUserId and enabled) doesn’t seem to make a difference:

curl https://api.nuki.io/smartlock/1805XXXXX/auth -X PUT -H “Content-Type: application/json” -H “Accept: application/json” -H “Authorization: Bearer XXXXXXXXX” -d “{ “name”: “GeorgeLukas7”, “allowedFromDate”:“2022-12-25T11:00:00.000Z”, “allowedFromTime”: 0, “allowedUntilDate”: “2022-12-28T10:00:00.000Z”, “allowedUntilTime”: 0, “allowedWeekDays”:127, “accountUserId”: 0, “enabled”: true, “remoteAllowed”: true, “type”: 13, “code”: 181830 }”
{“code”:422,“description”:“The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions”,“homeRef”:"/",“reasonPhrase”:“Unprocessable Entity”,“uri”:“HTTP Extensions for Distributed Authoring -- WEBDAV”}

Ah, just saw ‘the same sequence’.

Tried it, no difference.

curl https://api.nuki.io/smartlock/18051XXXX/auth -X PUT -H “Content-Type: application/json” -H “Accept: application/json” -H “Authorization: Bearer XXXXXXXXXXX” -d “{ “name”: “GeorgeLukas8”, “allowedFromDate”:“2022-12-25T11:00:00.000Z”, “allowedUntilDate”: “2022-12-28T10:00:00.000Z”, “allowedWeekDays”:127, “allowedFromTime”: 0, “allowedUntilTime”: 0, “accountUserId”: 0, “enabled”: true, “remoteAllowed”: true, “code”: 181831 }”
{“code”:422,“description”:“The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions”,“homeRef”:"/",“reasonPhrase”:“Unprocessable Entity”,“uri”:“HTTP Extensions for Distributed Authoring -- WEBDAV”}

I see the code contains a ‘0’ and it is not possible to set a code with null. Is this a typo?

I believe this format for the date works:
“allowedFromDate”: “2022-12-21”
“allowedUntilDate”: “2022-12-23”

Well, to conclude the question in the post, the date works correctly in the format 2022-12-25T11:00:00.000Z. It was the initial curl command that had an error, which was fixed later.