how get login through api and get data

mohamed_fadol4 years ago

hi guys

I using laravel api to get all user or one user when check api by postman to get response ,
i get

{
"servlet":"org.eclipse.jetty.servlet.DefaultServlet-36ef1d65",
"message":"Not Found",
"url":"/users/5/",
"status":"404"
} 

the url with method get is : http://mydomain:8082/users/5/?token=VNO86MV0QiPBTDdnD6RRMwNpPxZDLhrC
what is wrong , or how make login first and how get data in the end ,
please solution with code :)
thanks for hardwork :)
nots : documentation I read it , but need help according on my knowledge :)

ss884 years ago

The API is

 api/users 
not just
 /users 
so you should try with :

http://mydomain:8082/api/users/5/?token=VNO86MV0QiPBTDdnD6RRMwNpPxZDLhrC

instead.

mohamed_fadol4 years ago

thanks ss88 for qu-replay :)

how make login and being authorized to do more in system,
then :
how get token , where can i get it

thanks bro ss88 :)

mohamed_fadol4 years ago

this result for each request in postman

HTTP 404 Not Found - NotFoundException (...)
Anton Tananaev4 years ago

You cannot request a single user, at least not yet. You can only get all users with GET /api/users.

mohamed_fadol4 years ago

thanks Anton :)

but every request i get this message => HTTP 404 Not Found - NotFoundException (...)
and when request for get => api/users
i get this message => HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:113 < ...)

what is wrong

thanks advance

Anton Tananaev4 years ago

The error message is pretty self explanatory. Authorization failed. There are two options for authorization:

https://www.traccar.org/traccar-api/

mohamed_fadol4 years ago

thanks sir Anton for replay :)
now i want to signup user with below function

public static $host='http://mydomain:8082';
private static $adminEmail='user';
private static $adminPassword='user';
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';

public static function signup($name,$email,$password){
    $name = $name;
    $email = $email;
    $password = $password;
    $data='{"name":"'.$name.'","email":"'.$email.'","password":"'.$password.'"}';
    return self::curl('/api/users','POST','',$data,array(self::$jsonC));
}

this function work good but return all data null (name, email,password)
what is problem

thanks advance