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

13,231

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!

Share:
13,231
ImDrPatil
Author by

ImDrPatil

Updated on June 06, 2022

Comments

  • ImDrPatil
    ImDrPatil almost 2 years

    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
    
  • Andy Aldo
    Andy Aldo almost 7 years
    Great. Can you accept my answer if it answers your question? @ImDrPatil