Thanks
I found the solution in :
https://www.traccar.org/api-reference/#tag/Permissions
Anton, I know how bad it is to hear other people's problems, but I wouldn't be here if I had understood the API documentation.
No matter how much I read and re-read it, the negative result is always the same... I know I must be doing something wrong.
The only way I was able to do this was by accessing the tc_user_device table (via mySQL) and changing the "deviceid" field. But this way is not functional, as you need to reload the web page for the device to be displayed.
The strange thing is that I can execute all the API commands successfully, I just can't assign the device to another user.
1 I log in with user admin on the API = OK
2 I create the device in my user = Ok
But I can't assign it to another user, see below:
Loged with Admin
URLhttp://XXX.251.222.19:8082/api/permissions
Metod : POST
Data:
{"userId":27,"deviceId":237,"groupId":0,"geofenceId":0,"notificationId":0,"calendarId":0,"attributeId":0,"driverId":0,"managedUserId":0,"commandId":0}
Response:
EIdHTTPProtocolException
Message error: HTTP/1.1 400 Bad Request
Can you see where I'm going wrong?
{}'s Miro (Brazil)
PS.
Headrs:
Request.ContentType := 'application/json';
Request.Accept := 'application/json';
Request.BasicAuthentication := True;
Request.Username := edUser;
Request.Password := edPassword;
The data should be (only include what's needed):
{"userId":27,"deviceId":237}
So it worked!!!
But partially working. It still depends on a reload of the web page to be shown.
Is this behavior normal?
Yes, that's expected.
Creating a Device via API with immediate visualization, without reloading the web page.
Traccar version 5.9
It's a paleative solution, but it solved my pain!
... And, that's all!
Miro (Brazil).
Hello everybody!
What would be the way to create devices for other Traccar users via API?
I'm using an application made in Delphi to create devices. But I can only create it if I am logged in on behalf of the target user.
This is not always possible, as the user can change their password..