Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eddy1992's avatar

Token mismatch when sending post request on PostMan

Hi I created a simple post route named test and I calling the route from the PostMan. I encounter the token mismatch error

The route I created

use Illuminate\Http\Request;

// PagesController Routes Starts
Route::post('test', function(Request $request){
    dd($request->all());
});

But it gave me this instead

TokenMismatchException in compiled.php line 3227:

Please assist

Thank You.

0 likes
2 replies
jekinney's avatar

By default all web post routes (post, put and delete) use the csrf middleware to check and verify the request has the token and it matches.

That is your issue most likely.

You either need to use an API route (if using l5.3) or in the middleware add the route in there so it doesn't check that route.

https://laravel.com/docs/5.3/csrf#csrf-excluding-uris

Explains it pretty well in the docs.

1 like
SwissNight's avatar

Actually you must add this lines of code. In App\Http\Kernel.php add this:

protected $routeMiddleware = [
    'csrf' => \Http\Middleware\VerifyCsrfToken::class,

(just add 'csrf' line)

and in:

protected $middlewareGroups = [
    'web' => [
//\App\Http\Middleware\VerifyCsrfToken::class,

commit VerifyCsrfToken class: (just commit with //)

After it will work

It happends because laravel needs always the token

3 likes

Please or to participate in this conversation.