You are using invalid group id. In your example group id is 1 not 0:
"id": 1
The groupId
parameter in group model refers to parent group of the group, which is not set in your case.
Ok thanks,
sorry, but:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic xxxxxxxxxxxxxxx" -d '{"deviceId": "2", "groupId": "1" }' "https://xxxxxxxxxxxxxxx/api/permissions"
Table "TC_DEVICE_GROUP" not found; SQL statement:
INSERT INTO tc_device_group (deviceId, groupId) VALUES (?, ?) [42102-199] - JdbcSQLSyntaxErrorException (... < QueryBuilder:65 < *:135 < DataManager:438 < PermissionsResource:63
or
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic xxxxxxxxxxxxxxx" -d '{ "groupId": "1", "device": "2" }' "https://xxxxxxxxxxxxxxx/api/permissions"
Table "TC_GROUP_DEVICE" not found; SQL statement:
INSERT INTO tc_group_device (groupId, deviceId) VALUES (?, ?) [42102-199] - JdbcSQLSyntaxErrorException (... < QueryBuilder:65 < *:135 < DataManager:438 < PermissionsResource:63 < ...)
Now I'm not sure what the issue is. Check database to see if id is still valid. One thing I don't understand is why you are trying to send numeric values as strings.
Hello,
I reinstall Traccar with docker and mariadb on another host.
I try again curl api commande and I have the same error.
Table 'traccar.tc_group_device' doesn't exist - SQLSyntaxErrorException (... < QueryBuilder:480 < DataManager:441 < PermissionsResource:63 < ...)
And effectively, I don't have the tc_group_device in database.
How I can create it with rights options?
Thanks
If you don't have a table, then it means something was wrong with migration. It can indicate much bigger problems. You need to find the root cause.
Thanks,
New traccar from scratch. No migration.
Can you or someone, just said to me the type of table of tc_group_device. To create.
Thanks
Migration is done even on clean installation. It initializes the database.
Hello,
I try to find something about git grep tc_group_device in code, but nothing.
https://github.com/traccar/traccar/blob/master/schema/changelog-4.0-clean.xml
Don't find tc_group_device
git grep tc_group_device
Don't find tc_group_device
Maybe there is no table tc_group_device by default?
Thanks
Just checked. Correct, such table doesn't exist. Sounds like you are using wrong API requests.
Thanks
Simple question.
Is it possible to link device to group?
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic xxxxxxxxxxxxxxx" -d '{ "groupId": 0, "deviceId": 2 }' "https://xxxxxxxxxxxxx/api/permissions"
Yes, but that's not how you do it. There is a groupId
field in the device model.
OK,
I created table like this:create table tc_group_device (groupid int, deviceId int);
And curl this:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic xxxxxxxxxxxxxxx" -d '{ "groupId": 0, "deviceId": 1 }' "https://xxxxxxxxxxxxx/api/permissions"
And when I request GET by api the device, groupid appears!
Is it correct?
Thanks
It is incorrect.
Hello,
Traccar v4.6 standalone.
Maybe I don't understand, but I cannot use api with groupId
GET groups
GET devices?id=2
Or
but
WORKS!
I see this post:
[topic apipermissions]:(https://www.traccar.org/forums/topic/apipermissions/)
My traccar not use an database mysql.
Thanks