【问题标题】:Post method not working when I use postman for run API In laravel 5.1 API当我在 laravel 5.1 API 中使用邮递员运行 API 时,发布方法不起作用
【发布时间】:2019-01-10 15:38:51
【问题描述】:

控制器代码:public function xyz(){echo 'hello';}

Route::group(['prefix' => 'api'], function(){Route::post('apiregstration','APIcontroller@xyz');});

我使用 laravel 5.1 并想用 post 方法创建 API 但它不起作用, GET方法工作正常

【问题讨论】:

  • 究竟什么“不起作用”?预期的行为与实际发生的情况是什么?我们无法理解仅使用该代码发生了什么,因此请更新您的问题并包含尽可能多的详细信息。
  • postman return error 404 error with html code error

标签: php api laravel-5 laravel-5.1


【解决方案1】:

如果 get 有效但 post 无效,也许您应该尝试运行 php artisan route:clearrun 以清除路由缓存。

【讨论】:

    【解决方案2】:

    您的 sn-p 中似乎有一个错字(我假设它直接来自您的来源)。

    尝试改变

    Route::group(['prefix' => 'api'], function() {
        Route::post('apiregstration','APIcontroller@xyz');
    });
    

     Route::group(['prefix' => 'api'], function() {
        Route::post('apiregistration','APIcontroller@xyz');
    });
    

    我假设您的意思是 'apiregistration' 而不是 'apiregstration'

    我们无法假设、测试或检查您提供的信息。 如果错误没有消失,请尝试在问题中添加更多代码,以便我们提供帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-19
      • 2018-08-07
      • 1970-01-01
      • 2018-06-25
      • 2017-03-01
      • 2019-05-06
      • 1970-01-01
      • 2019-10-01
      相关资源
      最近更新 更多