Question

I have created many Api's (both GET and POST) but now I want to create the custom search API with different URL Structure (all the params after ?).

I can create the search API in below URL formate..

/V1/getSearch/vendor/:vendArea/type/:typeId

but I want to achieve the same with below given formate..

/V1/getSearch/?vendor=bangalore&type=2

Any body have idea to get this formate ?

Was it helpful?

Solution

finally achieved this..

there is nothing special we need to define in XML or Interface we simply need construct the instance of Magento\Framework\App\Request\Http into the class where we are making our method.

for example:

function __construct( Magento\Framework\App\Request\Http $request) {

 $this->_request                 = $request;

}

public function getParam(){

 $filter = $this->_request->getParam('filter');

}

now filter will have the filter parameter value you passed in the API URL..

Hope this will help.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top