SOLVED - REST API: Get positions only for manager?

pavelik7 years ago

Hallo,
I can send GET request http://IP/api/devices without problems by "normal" user without problems. I can see this response:

[
    {
        "id": 3,
        "attributes": {},
        "name": "tracker",
        "uniqueId": "XXXXXXX",
        "status": "online",
        "lastUpdate": "2017-11-11T11:41:11.038+0000",
        "positionId": 3474,
        "groupId": 0,
        "geofenceIds": [],
        "phone": "XXXXXXXX",
        "model": "",
        "contact": "",
        "category": "person"
    }
]

When I try GET request http://IP/api/positions to get last know position of user's devices. Server reply with:

Manager access required - SecurityException (PermissionsManager:158 < *:270 < PositionResource:76 < ...)

When I try it with admin credentials, all works as expected.

Why? Documentation https://www.traccar.org/api-reference/#path--positions tells:

Without any params, it returns a list of last known positions for all the user's Devices.
Thanks

Anton Tananaev7 years ago

This has been discussed countless number of times. You need to include Accept header with application/json as value with your requests.

pavelik7 years ago

Thanks, for your support. It is working now. I was searching forum before I have put question here, but nothings helps me. The problem is that newbie (as me) do not know, how to make right question.
For better searching... What about add tags to questions? And possibility to search by tags?

Have a nice day!

Serge Kostromin6 years ago

Hello!
Having Same problem with
api/events/id
request. Getting response:

HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:111 < ...)

Accept header with application/json value included. Autorization login - pass also included. How should I get events from demo5 server?