Non sto ottenendo il risultato (id) mentre utilizzo il metodo POST usando url is rest / V1 / hello / test / 3
Ho seguito questo link per riferimento Fare clic qui
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>
Ora ho cancellato cache e pagecache e ho aperto l'app postmen e ho mantenuto l'URL come http://10.0.0.33/nagarajuM2/rest/V1/hello/test/3
ma sto ricevendo un errore.
Per favore aiutatemi.