Laravel 419 Unknown Status (Ajax or Postman)

While submitting form through Ajax in Laravel or posting data from Postman, you are getting status code 419 Unknown Status Error, don’t worry, with the help of tutorial you can fix the error.

Laravel Status Code: 419 Unknown Status (Ajax or Postman)

To fix ajax 419 status code unknown status in Laravel 11, 10, 9 and 8 version; is as follows:

Solution 1 – 419 unknown status laravel form submit

To add the following line of code into your blade view file head section: is as follows:

<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>

Then get the csrf token and add with ajax code in laravel: is as follows:

$.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});
 
$.ajax({
    
});

Solution 2 – 419 unknown status laravel ajax post

To add the following line of code into your blade view file head section: is as follows:

<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>

Use the following code to send csrf token with your form data using ajax in laravel: is as follows:

$.ajax({
    type: "POST",
    url: '/your_url',
    data: { somefield: "Some field value", _token: '{{csrf_token()}}' },
    success: function (data) {
       console.log(data);
    },
    error: function (data, textStatus, errorThrown) {
        console.log(data);
 
    },
});

Solution 3 – Laravel 419 error on POST request via POSTMAN

Just navigate to the app/http/middleware directory and open VerifyCsrfToken.php file. And then add your routes into it; like following:

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;

class VerifyCsrfToken extends Middleware
{

    protected $addHttpCookie = true;

   protected $except = [
    'auth/facebook/callback',
    'auth/google/callback',
];
}

Recommended Laravel Tutorials

Leave a Comment