0

I am using Codeigniter 3.1.0, Restserver downloaded from here with documentation from here. I am also using Chrome's extension Postman.

The problem is that even if i choose POST from the drop down menu of Postman, it hits the get method... Below is the code:

defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH . '/libraries/REST_Controller.php';

class Example extends REST_Controller {
    function __construct() {
        parent::__construct();
    }
    public function users_get() {
        echo "get request";
    }
    public function users_post() {
        echo "post request";
    }
}

Now through Postman, if i choose GET to the URL example-domain.com/api/example/users the preview is get request

If i choose POST to the same URL example-domain.com/api/example/users the preview is again get request and not post request

I didn't change anything in config/rest.php and i am using the implemented example of the Restserver in controllers/api/example

Does anyone know why i can't hit the POST method?

GeorgeGeorgitsis
  • 1,262
  • 13
  • 29

1 Answers1

1

Finally i found what caused the issue. I had previously installed SSL on this domain but i was trying to call the API with HTTP.

In .htaccess i had the rewriterule

RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

to force HTTPS.

If i make a POST request with HTTPS it works like a charm.

If i make a POST request with HTTP it redirects to HTTPS (because of the rewrite rule), therefore there is a new GET request to the new page.

GeorgeGeorgitsis
  • 1,262
  • 13
  • 29