mmik
mmik

Reputation: 5981

MethodNotAllowedHttpException in RouteCollection.php line 219 using Postman

I've a simple POST route setup on my routes.php file and it pointed to a controller method called authenticate.

routes.php

Route::group(['middleware' => ['web']], function () {
    Route::post('/authenticate', 'TrackerAuthenticationController@authenticate');
});

TrackerAuthenticateController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class TrackerAuthenticationController extends Controller
{
    public function authenticate(Request $request) {
        return 'success';
    }
}

However, when I send a POST request using the Postman HTTP client it returned error MethodNotAllowedHttpException in RouteCollection.php line 219. It doesn't return the success message. Is there anything I'm missing?

Upvotes: 0

Views: 2821

Answers (1)

mmik
mmik

Reputation: 5981

The issue I was experiencing is caused by the CSRF token. Disabling the CSRF token from the VerifyCsrfToken class resolved this.

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'authenticate'
    ];
}

Upvotes: 0

Related Questions