I am trying to create a REST API in an advanced Yii2 application to manage simple queries in my database. Following some tutorials, finally build a step-by-step example in the Quick Start Guide and get my model working for the GET and HEAD methods.
Created my API service inside the module, correctly configured with minimal settings, requested the JSON parser on backend / main.php, registered the general module /main.php and created a rule in urlManager there too (below the minimum normal rule, enablePrettyUrl, controller / action ,. ..):
['class' => 'yii\rest\UrlRule', 'controller' => ['precapi']]
But whenever I tried other methods, via CURL or Postman REST Client, it always gives me 405 error:
The method is not allowed. This URL can only process the following request methods: GET, HEAD.
I think I tried so many different configurations and paths, trying to solve it, but without any results. In urlManager there is only 'enableStrictParsing' => false' because it gives me a 404 error on some URLs, and POST does not work with this either, although the application works as usual.
Any help would be appreciated. Sincerely.
yii2 yii2-advanced-app
user3627496
source share