1

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 ?

0

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.

  • can you post complete code. – Alok Singh Aug 28 '18 at 10:59
  • @AlokSingh in your API method you can get do the above thing, alternatively you can use RequestInterface to ge the above data. – Mohammad Mujassam Aug 30 '18 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.