繁体   English   中英

不允许使用Slim Framework方法。 必须是以下之一:POST(405)

[英]Slim Framework Method not allowed. Must be one of: POST (405)

我在slim框架中编写了REST api。 当我从浏览器调用authenticate API时,它会使用'Method not allowed。 必须是以下之一:POST' 以下是我的代码,请在我出错的地方纠正我。

的index.php

<?php

require 'vendor/autoload.php';
require 'Authenticate.php';

$app = new \Slim\App;

$app->post('/api/authenticate', \Authenticate::class);

$app->run();

的.htaccess

RewriteEngine On
RewriteRule ^ index.php [QSA,L]

网址

http://localhost/project/api/authenticate

如果您在浏览器中键入URL,则该方法将是GET而不是POST 您可以使用Postman或您选择的其他替代方法来测试您的REST API以用于其他方法,如POSTPUTDELETE等。

有关HTTP方法的更多信息,请访问

希望能帮助到你!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM