Assigning a Driver to a Device via API

Truness23 days ago

I'm trying to assign a driver to a device using the Traccar API, but the request is not working as expected. I’d like to confirm if my request is correct or if there's a different approach I should take.

Request I'm Using:

POST /api/permissions

{
  "deviceId": 8,
  "driverId": 5
}

Questions:

Is this the correct endpoint for assigning a driver to a device?

Are there any prerequisites, such as specific permissions or configurations, needed for this request to work?

If this is not the correct method, what is the proper API request to link a driver to a device?

I appreciate any help! Thanks in advance.

Anton Tananaev23 days ago

What's not working exactly? The request looks good, assuming the ids are correct.

Truness22 days ago

I recorded a video explaining the issue in detail. At the beginning, I show that for some devices, the driver's name is displayed correctly, while for others, it does not appear, even after selecting the option to show the driver in the pop-up.

Next, I perform three requests:

  1. Retrieve the driver information.
  2. Retrieve the device data.
  3. Assign the driver to the device.

After that, I check and confirm that the update did not take effect as expected. At the end of the video, I demonstrate that the driver is still not displayed, even after the device updates its location.

You can watch the video here: https://youtu.be/vG_j5rSd61s.

Anton Tananaev21 days ago

Based on the video it seems like you misunderstand what linking driver to a device does. It just means that certain driver is authorized to drive certain vehicle. To be able to see it in the popup your device needs to report driver id.

Truness21 days ago

Got it! What is the Traccar endpoint and body I can use to report this driver on the device?

Anton Tananaev21 days ago

Your device has to do it. What device are you using?

Truness21 days ago

I am using a J16 tracker ( GT06 protocol ) and want to integrate it with my website. The idea is for the driver to access the site, enter their identification and the device code, and have this information automatically sent to the tracker, updating the assigned driver.

My website is ready, but I’m stuck on how to communicate with the tracker to register the driver.

Anton Tananaev21 days ago

Does your device even support this functionality? Have you checked with your device vendor?

Truness21 days ago

I believe so, but the main goal is to set this via API in Traccar. The idea is for the driver to access a website ( without any direct connection to the device ) to assign themselves, instead of using RFID readers or IButtons.

Anton Tananaev21 days ago

Then you should probably just use processing.useLinkedDriver:

https://www.traccar.org/configuration-file/