Geoff
Geoff

Reputation: 6639

Laravel post request returns a method not allowed

In my routes file I have

Route::post('/request-rest-password', 'HomeController@requestResetPwd');

IN the controller

  public function requestResetPwd(Request $request){
      return $request;
  }

Now whenever I try post it always throws an error

"exception": "Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException","file": "/var/www/html/freelancer/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",

Where could I be going wrong Example of a post

$ curl -X POST -H "Accept: application/json" -F "[email protected]" -F  ....... 
        "http://localhost:8000/request-reset-pwd"

Upvotes: 0

Views: 1982

Answers (2)

Akbar Soft
Akbar Soft

Reputation: 1066

Route::post('/request-rest-password', 'HomeController@requestResetPwd')->name('post_insert');

and your form html should contain route like this ...

<form method="post" action="{{route('post_insert')}}">
{{csrf_field()}}
  your user fields goes here...
</form>

Upvotes: 0

aze&#243;s
aze&#243;s

Reputation: 4901

You have a typo:

Route: request-rest-password
POST: request-reset-pwd

Upvotes: 2

Related Questions