Getting speed/distance units via API

alexbk66 5 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 Tananaev 5 years ago

Session endpoint.

alexbk66 5 years ago

Thank you Anton

alexbk66 5 years ago

Hmm

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

That means you are not logged in.

alexbk66 5 years ago

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

alexbk66 5 years ago

And even in browser Attributes are empty:

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

Empty means default.

alexbk66 5 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"}
alexbk66 5 years ago

But via API I still get 404 for session

alexbk66 5 years ago

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

alexbk66 5 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 Tananaev 5 years ago

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

alexbk66 5 years ago
alexbk66 5 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?