What scheme and API are you talking about? Please be more specific.
Thanks for anwswer
To relate geofence and device I use the path /devices/geofences using body with deviceId and geofenceId
I checked the database and the data is correctly related.
The path to GET all devices is /devices using GET without any param
Thanks again
What exactly is not working?
By example i have 1 device with 2 geofences. When i get devices using the API i have this answer:
[ { "id": 3, "attributes": { "speedLimit": "2" }, "name": "Device 1", "uniqueId": "867273028860984", "status": "offline", "lastUpdate": "2017-01-24T02:44:30.000+0000", "positionId": 5679, "groupId": 0, "geofenceIds": [], "phone": "", "model": "", "contact": "", "category": "arrow" } ]
If you can see the array for geonfenceIds is empty.
I think you are mistaking two things. The field that you are talking about contains ids of the geofences that the device is currently in. It's not the same as the list of all geofences linked to the device.
OH i understand!
Do you have more detailed info about the api?
Second question using the API Is there a way to get geofences associated with device ?
All the API documentation is here:
https://www.traccar.org/traccar-api/
For more details you should check the source code.
To get geofences for a device, you should use "/geofences" resource with "deviceId" parameter.
Thanks Anton!
Great Help.
Best Regards
hello,
first of all sorry for writing on a old thread. I think my question is related to this topic.
My question is, can I read relational table data using API? or how can I do that?
For an example, there is the relational table tc_device_geofence. I want to read data from this table.
thank in advance for the help.
Best regards
Not directly, but you can do something like this:
GET /api/geofences?deviceId=1
It will return data based on tc_device_geofence
.
Thanks much Anton for your reply.
Can I filter devices by geofence without adding goefenceId as a foreign key to the tc_devices
table??
That doesn't seem to be related to the topic.
Hello
Is there any way to read devices
by geofenceId
from tc_device_geofence
table? seems like GET /api/devices?geofenceId=1
is not working for the relation table.
please help me to figure out. Thanks.
Not possible in the current version of Traccar.
According to the scheme when obtaining the devices an arrangement with the IDs of the geofences should be obtained too but not working. Can you tell me if i need extra step?
Actually i do:
Please your kindly help.
Regards