I am trying to send a post request to a Laravel project using Postman, but I get a "419 unknown status" response
routes\web.php:
Route::post('/myaction', 'MymodelController@myaction');
app\Http\Controllers\MymodelController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Mymodel;
class MymodelController extends Controller
{
function myaction()
{
return redirect('/');
}
}
Why does this happen?
The same error appears independently of the content of myaction()
Laravel API to Postman is a package by Andreas Elia that allows you to automatically generate a Postman collection based on your app’s API routes. After you install the package, you can run the following artisan command, which will automatically generate a postman collection by introspecting your app’s API routes: 1 php artisan export:postman
When we send a POST request we generally intend to have some modification at the server such as updation, deletion or addition. One of the classic example of a POST request is the Login page.
After you install the package, you can run the following artisan command, which will automatically generate a postman collection by introspecting your app’s API routes: Postman is a popular API development GUI that simplifies building and testing APIs.
To perform HTTP requests with Laravel Http Client you can directly import and use the facade right away like below. The Http facade comes with "get", "post", "put", "patch" and "delete" methods as follows.
As you are requesting api you should write your route in api.php
instead web.php
web.php
require _token
the csrf field
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With