Please provide more details on how you're trying to use it.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://traccar.example.com/api/devices?token=8ZnQ1vU6xKxLqQIW6fLXVZw6KdXCkYQS',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response:
HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:113 < ...)
Yeah, you can't use the token that way. You have to create a session first.
can you please share the endpoint to create a session?
Have you read our API documentation?
yeah but my version is 4.12 in new docs they said to use username:pass but can we do that with out basic auth?
Have you read this?
yes, I call the endpoint of api/session?token=8ZnQ1vU6xKxLqQIW6fLXVZw6KdXCkYQS
I got this response
{"id":4,"attributes":{},"name":"test.allotrac","login":"","email":"test@allotrac.com.au","phone":"","readonly":false,"administrator":false,"map":"","latitude":0.0,"longitude":0.0,"zoom":0,"twelveHourFormat":false,"coordinateFormat":"","disabled":false,"expirationTime":null,"deviceLimit":-1,"userLimit":0,"deviceReadonly":false,"token":"8ZnQ1vU6xKxLqQIW6fLXVZw6KdXCkYQS","limitCommands":false,"poiLayer":"","password":null}
Now what to do?
Then you use the session cookie for your next requests.
Do you mean JSESSIONID which is in the response of the server header?
Yes.
Hello,
We had some stuff back from google today regarding an indexing issue from a link as I posted the full link of the site and there is no option to delete or edit my comment.
Can you please help me to edit or delete this to solve my problem?
Thanks
Changed the link.
When I try to get devices using my token it give an unauthorized error
but when I called it from the web where traccar is configured it uses some Jsession id i think
when I get JSESSONID from api it doesn't work