userId parameter not working with /api/users/

masterkitano6 years ago

When I try to use "/api/users?userId=1" to retrieve specific user, it shows an empty array. I have verified and the user from which Im authenticating to use the API does have Admin permissions. Any clues?

Anton Tananaev6 years ago

Where did you get the parameter from? I don't see it in the documentation.

masterkitano6 years ago

https://www.traccar.org/api-reference/#path--users

It states the following:
userId Can only be used by admin or manager users type: query string
The real question would be, how can I retrieve a single user data by ID?
most APIs has the index route: users/ to retrieve a list of users, but also users/id to retrieve a user data by its id.

Anton Tananaev6 years ago

That's not for retrieving specific user. It's for retrieving list of users managed by specific user.

masterkitano6 years ago

So, is there a way to retrieve specific user data by user ID? I would not like to get all users each time I search for it.

Anton Tananaev6 years ago

It's not possible at the moment. We usually just cache users.