2

Yii2 Restful API

In the above link they mention for GET Search method , Please anyone tell me for like POST create and PUT Update ...

In main.config under rules i created like,

['class' => 'yii\rest\UrlRule', 'controller' => 'v1/lkup-access-profile','extraPatterns' => ['POST create' => 'create']],

But its comes error as Method Not Allowed. This url can only handle the following request methods: POST.

1 Answer 1

0

yii\rest\UrlRule will create default REST URLs and actions. There's no need to add 'extraPatterns' => ['POST create' => 'create']. It's already built in. Check out the docs http://www.yiiframework.com/doc-2.0/yii-rest-urlrule.html

Use extraPatterns to extend default routes for controller. For example

['class' => 'yii\rest\UrlRule', 'controller' => 'v1/invite',
    'extraPatterns' => [
        'PUT {id}/accept' => 'accept',
        'PUT {id}/reject' => 'reject',
    ],
],
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.