问题
I have written REST api in slim framework. When i call authenticate API from browser it troughs 'Method not allowed. Must be one of: POST'. Below is my code, please correct me where i went wrong.
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]
URL
http://localhost/project/api/authenticate
回答1:
if you type the URL in the browser, the method is going to be GET
instead of POST
. What you can do is use Postman or other alternatives of your choice to test your REST API for other methods like POST
, PUT
, DELETE
, etc.
More info about HTTP methods here
Hope it helps!
来源:https://stackoverflow.com/questions/45064254/slim-framework-method-not-allowed-must-be-one-of-post-405