I can see that postman is being redirected for some reason. I have just started using postman so not sure what a normal request would look like. When I make the following request;
POST https://development.example.com/Api/Register
form-data
KEY name
VALUE Thomas
KEY _method
VALUE PUT
For some reason it returns my top page of my website. When I look at the apache2 log file, I can see:
124.xxx.xxx.xxx - - [27/Feb/2022:09:08:36 +0000] "POST /Api/Register HTTP/1.1" 303 5724 "-" "PostmanRuntime/7.28.4"
124.xxx.xxx.xxx - - [27/Feb/2022:09:08:36 +0000] "GET / HTTP/1.1" 200 8185 "https://development.example.com/Api/Register" "PostmanRuntime/7.28.4"
When I access it through a web browser like chrome (and I cannot submit any values of course), I get below which is expected;
{
"status": 500,
"message": {
"name": "The name field is required",
"email": "The email field is required",
"password": "The password field is required.",
"password_confirmation": "The password_confirmation field is required."
},
"error": true,
"data": []
}
What am I doing wrong with POSTMAN please?
My Users
controller is;
public function userRegister(){
$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);
}
What is also puzzling is that the route is NOT accessible via;
My routes file is;
$routes->group('Api', ["namespace" => 'App\Controllers\Api\v1'] , function($routes){
$routes->post('Register', 'Users::userRegister');
});
https://development.example.com/Api/Register
Error; Controller or its method is not found: \App\Controllers\Api\Register::index
https://development.example.com/Api/v1/Users/userRegister
This will work and give correct error like way above.