TTLock API | errmsg: date must be current time, in 5 minutes

I had a problem when dealing with TTLock APIs. When I send a POST request, the date is requested in milliseconds, but when I enter the current time value, I get this message:

"date must be current time, in 5 minutes".

Send POST request to TTLock API, to get a response, but it always sends me an error message. All the problem with the value of 'Date' parameter, what should I do?

The value which I write is like "1689420010".

In TTLock documents the description of 'date' parameter is "Current time (timestamp in millisecond)"

TTLock Documents: https://euopen.ttlock.com/document/doc?urlName=cloud%2Flock%2FlistEn.html

I tried in many ways, but I couldn't solve this problem. Please help me solve this problem.

Upvotes: 0

Views: 483

Answers (2)

Kishan Virani
Kishan Virani

Reputation: 11

Current Time (ms)
1702034564000

As per the documentation, you must pass the date in milliseconds with every API request. The date requested here is Epoch time(Unix time) in milliseconds.

You are receiving the error below because the TTLock API server allows time drift of 5 min between requests being sent from your system and the time they are received on the TTLock Server.

"date must be current time, in 5 minutes".

So you can use Date.now() in JS to get the current time in milliseconds.

If you are using Postman for testing requests, you can create a pre-request script to update the variable.

postman.setGlobalVariable('currentDate', Date.now());

Documetnation: https://euopen.ttlock.com/document/doc?urlName=cloud%2Flock%2FupdateLockDataEn.html

Upvotes: 1

Ante Filipović
Ante Filipović

Reputation: 16

I had same problem. Just convert timestamp in milliseconds After that everything work for me.

Upvotes: 0

Related Questions