Error API Traccar

Hello guys!!

I'm trying to use the apc Traccar via php and is giving the error:

HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter: 111 <...) 401

In my header I have:

public static $host='http:/meuip:8082';
private static $adminEmail='admin';
private static $adminPassword='minha_senha';
public static $cookie;
private static $jsonA='Accept: application/json';
private static $jsonC='Content-Type: application/json';
private static $urlEncoded='Content-Type: application/x-www-form-urlencoded';

I think the error is being triggered by the way I call functions.
Look at this example:

$b = gps::devices('What_I_put_here?','6');
echo $response = $b->response;
echo $responseCode = $b->responseCode;

You can help me???

Ernesto Vallejo5 years ago

Would recommend you to use postman. Postman will show you example code for php.

Thanks for the feedback Ernesto.

I am in doubt only with such $sessionId. See:

public static function devices($sessionId,$id){
    if($id != ''){
        $data='id='.$id;
    }
    return self::curl('/api/devices?'.$data,'GET',$sessionId,'',array());
}

How do I get this $sessionId??

In your link, JBFelisberto did so: $ sessionId = gps :: $cookie;
But where does he get that $cookie??

Jose B5 years ago

from/into file traccarApi-1.1.php

JB

SHOW!!!! Perfect!!! Is working!!

Very; very; thanks;

Murthy Varanasi3 years ago

can u help me how u got session id. When i am trying
$sessiod=gps:cookie;
its says Undefined class constant 'cookie'
ANy help pls