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
}