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

依然范特西╮ 提交于 2019-12-23 21:25:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!