API-request format?

thomasw8 years ago

Hello,
I have my own Traccar-Server and it get's data from tracker and everything work fine.
But how I want to get some data via API - I just want to create the adress+parameter by my own.
I tried something like this (of course email and pw is replaced by real values)
http://myserver/api/devices?auth={"email:pw"}
http://myserver/api/devices?auth={"email":"pw"}

I only get something like
[]

What is missing. What am I doing wrong?

Thanks
Thomas

Anton Tananaev8 years ago

Where did you get this format? You need to either have a session or use basic HTTP auth.

thomasw8 years ago

Hello,
I get this format from geotab, where I send credentials like this:
https://my62.geotab.com/apiv1/Get?typeName=devices&credentials="userName":"thomas...","password":"mypw"}

what do mean by basic HTTP auth? something like this:
http://user:pw@myserver/api/devices
?
I tried it this way, but I get a popup (in firefox), that the page does not need any authentification. With Safari page can not be found.

Could you give me an example, how to get devices or any other data from the server?

Thanks
Thomas

Anton Tananaev8 years ago
thomasw8 years ago

But how can I add a header to the url in the browsen?! Is this possible?
http://user:pw@myserver/api/devices does not work - when I create RFC2045-MIME of user and pw, how can I add it to the url?

I also tried
curl -u user:pw http://myserverIP/api/devices
but I only get {}
It does not matter, what username or pw I use, I get not error, I always get {}

Do I have to enable something on the server?
Add username and pw I use my account, I created in my server's Traccar-WebInterface - I hope, this is OK

Do I have to add a port to the serverIP?

Or is there something else than api/devices I can try?

Thanks
Thomas

Anton Tananaev8 years ago

You need to use same URL as you use to connect to regular web interface. By default port is 8082. I don't know how and if it's possible to pass authorization header from browser.