I'm trying to send a POST request via the POSTMAN application to my API which is running Laravel 5.6.
My route is as follows:
Route::post('/charge','Charge@index');
and the Charge and index function simply var_dumps the post parameter:
class Charge extends Controller
{
public function index()
{
var_dump($_POST);
}
}
The response I get is a 419 unknown status error. I've got no idea what the problem is.
I'm unsure what other info to include here, but please ask if anything else would be needed to help solve this issue.
Thanks, J
It may be because you are not sending your CSRF token with the form data.
In laravel it is mandatory to send the CSRF token on every request.
If you don't want to send the token, you need to mention the method name in the app/http/middleware/VerifyCsrfToken.php
file.
<?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',
];
}