Magento 2 – How to Get Parameters Value from Post URL in REST API

magento2

How to get parameters value in string from post url in rest api in magento 2.
(I need username and password in my custom module).
http://…/Magento2/index.php/rest/V1/authorize?username=Arjun&password=2.
I am getting o as value and not string.

Best Answer

In the interface have you added docblock (/** /) This specifies what will be return type of your output and which is must? For my code I was just adding sum of two numbers so here is code of my interface as below,

interface CalculatorInterface
{
    /**
     * Add two numbers.
     *
     * @param int $num1
     * @param int $num2
     * @return int
     */
    public function add($num1, $num2);
} 
Related Topic