Php Laravel API在localhost中的postman中不起作用

Php Laravel API在localhost中的postman中不起作用,php,laravel,postman,laravel-artisan,artisan-serve,Php,Laravel,Postman,Laravel Artisan,Artisan Serve,我已经将API开发成PHPLaravel,并在本地服务器上开发并使用 php artisan serve 这些API在网站上运行,但每当我试图在postman中访问它们时,它就会返回带有消息的419响应代码 页面已过期 在通过谷歌搜索调试来自网站的请求后,我找到了与请求一起传递的标题。 所以我通过了 _token X-CSRF-Token 并在授权选项卡中选择了承载令牌。即使在头文件中添加了这些参数,也没有成功。我试着用body添加它们,但在那里也不起作用 代码片段是 Route::po

我已经将API开发成PHPLaravel,并在本地服务器上开发并使用

php artisan serve
这些API在网站上运行,但每当我试图在postman中访问它们时,它就会返回带有消息的419响应代码 页面已过期

在通过谷歌搜索调试来自网站的请求后,我找到了与请求一起传递的标题。 所以我通过了

_token 
X-CSRF-Token 
并在授权选项卡中选择了承载令牌。即使在头文件中添加了这些参数,也没有成功。我试着用body添加它们,但在那里也不起作用

代码片段是

Route::post('/register_user', 'MyUserController@storeApi');
MyUserController

 public function storeApi(Request $request)
 {   
     
        $userModel = new User;
        $userModel->first_name = $request->input('first_name');
        $userModel->last_name = $request->input('last_name');
        $userModel->save();
    
        $userId = DB::getPdo()->lastInsertId();

        $response['status'] = 'ok';
        $response['response'] = $userId ;
        return response()->json($response);
            
 }


所以我的问题是,如何使用postman在本地服务器上工作。

使用
api.php
文件 并使用api前缀调用路由,如下所示:

在api.php中

Route::get('/test','Controller@function');
GET: localhost:8000/api/test
在《邮差》中:

Route::get('/test','Controller@function');
GET: localhost:8000/api/test

使用
api.php
文件 并使用api前缀调用路由,如下所示:

在api.php中:

Route::get('/test','Controller@function');
GET: localhost:8000/api/test
在《邮差》中:

Route::get('/test','Controller@function');
GET: localhost:8000/api/test

您也应该共享代码,以便我们可以帮助您。@SachinBahukhandi我也添加了图像和代码。请检查更新的问题。只是为了确保您添加的是带有值的标题还是只有标题?@Borjante of course headers带有值。您也应该共享代码,以便我们可以帮助您。@SachinBahukhandi我也添加了图像和代码。请检查更新的问题。只是为了确保,您添加的是带有值的标题,还是仅添加带有值的标题?@Borjante of course headers。