Não estou obtendo resultado (id) enquanto estiver usando o método POST usando url is rest / V1 / hello / test / 3
Eu segui este link Para referência, clique aqui
1) webapi.xml
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/hello/name/:name" method="GET">
<service class="Inchoo\Hello\Api\HelloInterface" method="name"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/hello/test/:test" method="POST">
<service class="Inchoo\Hello\Api\TestInterface" method="test"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
2) TestInterface.php
<?php
namespace Inchoo\Hello\Api;
interface TestInterface
{
/**
* Returns greeting message to user
*
* @api
* @param id $name Users id.
* @return id Greeting message with users id.
*/
public function test($id);
}
3) Test.php
<?php
namespace Inchoo\Hello\Model;
use Inchoo\Hello\Api\TestInterface;
class Test implements TestInterface
{
/**
* Returns greeting message to user
*
* @api
* @param string $name Users name.
* @return string Greeting message with users name.
*/
public function test($id) {
return "Hello How are you your id is:," .$id;
}
}
4) di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Inchoo\Hello\Api\HelloInterface" type="Inchoo\Hello\Model\Hello" />
<preference for="Inchoo\Hello\Api\TestInterface" type="Inchoo\Hello\Model\Test" />
</config>
Agora limpei o cache e o pagecache e abri o aplicativo postmen e mantive o URL como http://10.0.0.33/nagarajuM2/rest/V1/hello/test/3
mas estou recebendo erro.
Por favor, me ajude.