(03-07-2022, 09:12 PM)kenjis Wrote: Code:
| GET | api/v1/user/list | \App\Controllers\Api\v1\User_controller::index |
| GET | api/v1/user/single/([0-9]+) | \App\Controllers\Api\v1\ApiController::?ingleEmployee/$1|
| POST | api/v1/user/add | \App\Controllers\Api\v1\User_controller::register |
| PUT | api/v1/user/update/([0-9]+) | \App\Controllers\Api\v1\ApiController::updateEmployee/$1|
| DELETE | api/v1/user/delete/([0-9]+) | \App\Controllers\Api\v1\ApiController::deleteEmployee/$1|
It seems if you POST /api/v1/user/add, \App\Controllers\Api\v1\User_controller::register is executed.
What if you add `dd('OK');` in the first line of the register() method?
Yes, indeed I tried that. Here is a recap of the results;
https://development.example.com/api/v1/user/add - browser - 404 Controller or its method is not found: \App\Controllers\Api\V1\User::add
https://development.example.com/api/v1/user/add - postman - returns top page of website
https://development.example.com/Testing/testmethod - blank page
:-(
PHP Code:
public function register(){
dd('ok');
$user = new UserEntity($this->request->getPost());
//$user->startActivation();
if ($this->UserModel->insert($user)){
$this->sendActivationEmail($user);
$response =[
'status' => 200,
'message' => 'User registed. Check email to activate account.',
'error' => false,
'data' => []
];
} else {
$response =[
'status' => 500,
'message' => $this->UserModel->errors(),
'error' => true,
'data' => []
];
}
return $this->respondCreated($response);
}
I noticed in the APACHE access log the following;
2xx.2xx.2xx.3x - - [08/Mar/2022:04:29:42 +0000] "POST /api/v1/user/add HTTP/1.1" 303 1062 "-" "PostmanRuntime/7.29.0"
This is a 303 error?
The next line shows;
2xx.2xx.2xx.3x - - [08/Mar/2022:04:29:42 +0000] "GET / HTTP/1.1" 200 8239 "https://development.example.com/api/v1/user/add" "PostmanRuntime/7.29.0"
of course example is a not the domain though.