Assigning a Driver to a Device via API

Trunessa year 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 Tananaeva year ago

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

Trunessa year 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 Tananaeva year 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.

Trunessa year ago

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

Anton Tananaeva year ago

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

Trunessa year 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 Tananaeva year ago

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

Trunessa year 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 Tananaeva year ago

Then you should probably just use processing.useLinkedDriver:

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

Martin Pascualon18 days ago

Hi Anton, questions about "use processing.useLinkedDriver"

  • will be possible to add then the driver as column in reports?
  • should we add the driverUniqueId as computed attribute?
  • should we use PUT /api/devices/{id} to set that attribute with api?

thanks in advance

Anton Tananaev18 days ago

will be possible to add then the driver as column in reports?

Depends on what report we're talking about.

should we add the driverUniqueId as computed attribute?

No.

should we use PUT /api/devices/{id} to set that attribute with api?

No.

Martin Pascualon18 days ago

Events for example because would be great to know which driver overspeed.

Is that report code in the server or in the client?

Anton Tananaev18 days ago

It won't be included there.

Martin Pascualon18 days ago

But the report are built in the server or the client?