'POST failed via Postman API to Laravel migrations database

GET is working, but POST does not. This is because it fails via Postman API to the Laravel migrations database.

function add_user(Request $request)
{
    $user = new user_a;
    csrf_token();
    $user->user_name = $request->user_name;
    $user->password = $request->password;

    $res = $user->save;
    if ($res) {
        return ["operationn" => "Done"];
    } else {
        return ["operation" => "failed_404"];
    }
}

in API file:

Route::post('registeruser',[dynamic_small_controller::class,'add_user']);

enter image description here



Solution 1:[1]

You are trying to send the password in integer format so it is not accepting try with giving password also in ""

{
   "user_name":"yahay",
   "password":"8888"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sagar Sheregar