Cannot seem to run commands for standard users..... Manager access required message

Gareth Curtis5 years ago

I have added a device with the admin user and given permission for this device to a standard user. I have logged into Traccar with that user and can see the device. The user does not have 'limit commands' option turned on.

I want to create about 5 of my own commands, ideally through the admin user and then have the standard user be able to run them (without adding that command to every device - or by using a group, because each user should only be able to see their own single device). I tried running an existing saved command created by the admin user:

POST: https://mydomain.com/api/commands/send
BODY:
{
    "id": 1
}

400:
Manager access required - SecurityException (PermissionsManager:178 < *:308 < CommandResource:64 < ...)

So instead I create my own version of the command (which as I say, I don't really want to do 50 times, on each device or user) but just to see if this would work:

POST: https://mydomain.com/api/commands
BODY:
{
    "deviceId": 1,
    "description": "[3G*8809001383*0008*POWEROFF]",
    "type": "custom"
}

200:
{
    "id": 5,
    "attributes": {},
    "deviceId": 1,
    "type": "custom",
    "textChannel": false,
    "description": "[3G*8809001383*0008*POWEROFF]"
}

I double check it has been added:

GET: https://mydomain.com/api/commands
200:
[
    {
        "id": 5,
        "attributes": {},
        "deviceId": 1,
        "type": "custom",
        "textChannel": false,
        "description": "[3G*8809001383*0008*POWEROFF]"
    }
]

I try to run it:

POST: https://mydomain.com/api/commands/send
BODY: {
    "id": 5
}

400:
Manager access required - SecurityException (PermissionsManager:178 < *:308 < CommandResource:64 < ...)

I also tried to just send a command (without saving it first) via that endpoint but it just saves it anyway, and doesn't send it.

I also tried commands/send which returns an empty body - bit confused about that?

GET: https://mydomain.com/api/commands/send?deviceId=1
200:
[]

I tried to update the command I just created:

PUT: https://mydomain.com/api/commands/5
BODY: {
    "deviceId": 1
}

400:
Manager access required - SecurityException (PermissionsManager:178 < *:353 < BaseObjectResource:125 < ...)

My questions are;

  1. Looking at the above, how can a standard user run commands please?

  2. Is there a way I can add my custom commands just the once, and have them available to X number of users or do I really need to add those custom commands to every device, or user?

Many thanks.

Anton Tananaev5 years ago

Compare your request with what official web app sends.

Gareth Curtis5 years ago

Ah so it's a bad request? Yes, I see now.

So the one I added via the UI (web interface) looks like this:

{
    "attributes": {
        "data": "[3G*8809001383*0008*POWEROFF]"
    },
    "deviceId": 1,
    "type": "custom"
}

Thanks. OK, so at least I can create and run a command now with the standard user now.... I'll just create each command on the client to workaround the other issue.