how to use controller name in rest url rules

hi there

i have this rule in my rest url rules:




 'rules' => [

                [

                    'class' => 'yii\rest\UrlRule',

                    'controller' => ['user', 'product'],

                    'extraPatterns' => [

                        'GET list/<store_id>/<category_id>' => 'list',

                    ],

                ],

            ],



but when i added controller-id like bellow, it can route me to correct page:




            'rules' => [

                [

                    'class' => 'yii\rest\UrlRule',

                    'controller' => ['user', 'product'],

                    'extraPatterns' => [

                        'GET products/list/<store_id>/<category_id>' => 'productlist',

                    ],

                ],

            ]



what should i do?

thanks in advance.

any help?

[color="#006400"]/* Moved from "General Discussions" to "REST APIs" */[/color]

how can i access my controller/action in rest with out define them in rules? just like web application!

Hi,

I am also facing the same issue. If you have solved this, Could you please help me on this?

Thanks

The solution is to not use pretty url :)

User [size=“2”]‘pluralize’ => false in your rule.[/size]




 'rules' => [

	[

		'class' => 'yii\rest\UrlRule',

		'controller' => ['user', 'product'],

		'pluralize' => false,

		'extraPatterns' => [

			'GET list/<store_id>/<category_id>' => 'list',

		],

	],

],