You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a restful resource to handle my api requests, like this: $routes->resource('api/categoria', ['controller' => 'Api\Categoria']);
When I make a PUT request, like this:
PUT localhost:8080/api/categoria/5 it works fine, calling the desired method inside the Categoria controller, update, in this case
But, when I make a request without an ID, it redirects to the index method inside the Categoria controller
My intention is when the user doesn't send an ID I will respond him with a fail message telling that an ID is required, but it is not working like that.
How to reproduce the error:
Fresh installation of CodeIgniter appstarter
Create a restful resource, like my example
Create a Controller and two methods inside: index() and update()
Use Postman to simulate a put request with and without an ID
When you make the request with an ID, it will be redirected to the update method, like expected.
But, when the ID is removed, it redirects to the index() method.
The only way I find out to fix this is creating manually the route that handles the PUT request, like so:
The text was updated successfully, but these errors were encountered:
reszko
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
Jul 17, 2020
reszko
changed the title
Bug: request to put/(:segment) redirects to index method instead update method
Bug: requests PUT type without segment redirects to index method instead update method
Jul 17, 2020
I have created a restful resource to handle my api requests, like this:
$routes->resource('api/categoria', ['controller' => 'Api\Categoria']);
When I make a PUT request, like this:
PUT
localhost:8080/api/categoria/5
it works fine, calling the desired method inside the Categoria controller, update, in this caseBut, when I make a request without an ID, it redirects to the index method inside the Categoria controller
My intention is when the user doesn't send an ID I will respond him with a fail message telling that an ID is required, but it is not working like that.
How to reproduce the error:
Fresh installation of CodeIgniter appstarter
Create a restful resource, like my example
Create a Controller and two methods inside: index() and update()
Use Postman to simulate a put request with and without an ID
When you make the request with an ID, it will be redirected to the update method, like expected.
But, when the ID is removed, it redirects to the index() method.
The only way I find out to fix this is creating manually the route that handles the PUT request, like so:
Environment: Localhost, windows 10
PHP 7.3.1
The text was updated successfully, but these errors were encountered: