Page 1 of 1

Login with API with username/password in URL fails

Posted: Fri Aug 02, 2024 6:52 am
by mgqz

Hello, I am trying to access my project with rest api but cannot login it says when I call this:
http://<my-ip>/agro-met/api/login?username=agromet_admin&password=<mypass>

{
    "statusCode": 200,
    "error": {
        "class": "text-danger",
        "type": "Error",
        "description": "C:\\xampp_81\\htdocs\\agro-met\\src\\phpfn.php(1843): PHPMaker2024\\agro_met\\FindUserByUserName(): Argument #1 ($username) must be of type string, null given, called in C:\\xampp_81\\htdocs\\agro-met\\src\\AdvancedSecurity.php on line 655"
    }
}

tried the sample project endpoint https://demo.hkvstore.com/api/list/cars and shows the data then

tried the same login with the sample project with same results:
https://demo.hkvstore.com/api/login?username=admin&password=master

thanks for any help


Re: Login with API fails error Argument # X must be of type string

Posted: Fri Aug 02, 2024 8:22 am
by mgqz

Hello, just an update, I noted via the swagger output that the parameters should be sent in the body of the request:

curl -X 'POST' \
  'http://83.147.37.52/agro-met/api/login' \
  -H 'accept: */*' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'username=<my_user_name>&password=<myPassword>'