I need a rest api to create a client in magneto so that I follow this tutorial http://www.authenticdesign.co.uk/extending-magento-rest-api-v2/
I followed it step by step, but when I test the api on the rest client, it gives me: {"messages":{"error":[{"code":404,"message":"Request does not match any route."}]}}
I do not know where I am wrong. Help me here as I am very new to magento as well as to php.
Steps:
1. The extension is included in (application / etc / module / Custom_Restapi.xml)
<config> <modules> <Custom_Restapi> <active>true</active> <codePool>local</codePool> </Custom_Restapi_Groups> </modules> </config>
2.config.xml at (app / code / local / Custom / Restapi / etc / config.xml)
<?xml version="1.0"?> <config> <modules> <Custom_Restapi> <version>0.1.0.0</version> </Custom_Restapi> </modules> <global> <models> <restapi> <class>Custom_Restapi_Model</class> </restapi> </models> </global> </config>
3.api2.xml at (app / code / local / Custom / Restapi / etc / api2.xml)
<?xml version="1.0"?> <config> <api2> <resource_groups> <restapi translate="title" module="Custom_Restapi"> <title>Custom Rest API</title> <sort_order>10</sort_order> </restapi> </resource_groups> <resources> <restapi translate="title" module="Custom_Restapi"> <group>restapi</group> <model>restapi/api2_restapi</model> <title>Testing My Rest API</title> <sort_order>10</sort_order> <privileges> <admin> <create>1</create> </admin> </privileges> <attributes translate="" module="Custom_Restapi"> <firstname>First Name</firstname> <lastname>Last Name</lastname> <email>Email</email> <password>Password</password> </attributes> <routes> <route> <route>/customer</route> <action_type>collection</action_type> </route> </routes> <versions>1</versions> </restapi> </resources> </api2> </config>
4. Model Class Restapi.php at (app / code / local / Custom / Restapi / Model / Api2 / Restapi.php)
<?php class Custom_Restapi_Model_Api2_Restapi extends Mage_Api2_Model_Resource { } ?>
5. V1.php at (app / code / local / Custom / Restapi / Model / Api2 / Restapi / Rest / Admin / V1.php)
<?php class Custom_Restapi_Model_Api2_Restapi_Rest_Admin_V1 extends Custom_Restapi_Model_Api2_Restapi { public function _create() { $requestData = $this->getRequest()->getBodyParams(); $firstName = $requestData['firstname']; $lastName = $requestData['lastname']; $email = $requestData['email']; $password = $requestData['password']; $customer = Mage::getModel("customer/customer"); $customer->setFirstname($firstName); $customer->setLastname($lastName); $customer->setEmail($email); $customer->setPasswordHash(md5($password)); $customer->save(); return json_encode(array("testing","Success")); } } ?>
And my url is like: baseurl / api / rest / customer