- Forums
- laravel
- [solved]: Postman Laravel Api Error - 403 This Action Is Unauthorized.
This Page Contains information about [solved]: Postman Laravel Api Error - 403 This Action Is Unauthorized. By jj in category laravel with 0 Replies. [5147], Last Updated: Mon Jun 24, 2024
jj
Sat Jun 03, 2023
0 Comments
616 Visits
403 THIS ACTION IS UNAUTHORIZED.
I am using Postman to test my Laravel API, I was sending a POST request to http://127.0.0.1:8000/api/files with {title:"",body:""} and thats when I received this error.
I am using StoreFileRequest, this is how the class looks like. Notice the authorized() method returns false, just change it to true;
class StoreFileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => ['required'],
'body' => ['required']
];
}
}
api.php
Route::resource('/files', FileController::class);
FileController:
public function store(StoreFileRequest $request) {
return response()->json($request, 200); // for POSTMAN testing
}