Getting speed/distance units via API

alexbk665 years ago

I get that the measurement units are reported in User Attributes, but I can't find how to get the current User?

Anton Tananaev5 years ago

Session endpoint.

alexbk665 years ago

Thank you Anton

alexbk665 years ago

Hmm

Execute(sync)[http://demo.traccar.org/api/session]: The remote server returned an error: (404) Not Found. 
Anton Tananaev5 years ago

That means you are not logged in.

alexbk665 years ago

It works in browser, but via API returns 404. But other calls work (server, devices, geofences, etc)

alexbk665 years ago

And even in browser Attributes are empty:

{"id":1520,"attributes":{},"name":"alexbk66",
Anton Tananaev5 years ago

Empty means default.

alexbk665 years ago

I did set units, but in browser was getting empty. But after setting other user Preferences (i.e. Map Layer) - the units now appear in Attributes:

{"id":1520,"attributes":{"distanceUnit":"km","speedUnit":"kmh","volumeUnit":"ltr"}
alexbk665 years ago

But via API I still get 404 for session

alexbk665 years ago

Do I actually need to create a new session in API first?

alexbk665 years ago

Yeah, I create a session and it returns attributes.
Thank you Anton.

PS. Probably there's a bug - if you create a new user and set user attributes - the attributes are not reported via API - unless you set any other user Preferences

Anton Tananaev5 years ago

Feel free to create a ticket on GitHub for the bug.

alexbk665 years ago
alexbk665 years ago

Anton,

So I'm reading the units in the user attributes (i.e. km) - but it looks like all distance values from API are in "m"?
So how do I know what are the actual units in API for Distance, TotalDistance, Altitude, Accuracy, Speed?