Running Magento V1.9 with Rest API
I can extract data using the REST api, but I need to exctract a list of categories and might even have the ability to add a new category through the API.
I have tried creating an module inside local and community folders, but I have this response returned.
exception 'Mage_Api2_Exception' with message 'Request does not match any route.'
QUESTION: Could it be caused by an error in my folder structure?
Inside api2.xml i think, theres must be a match between the route section and my call the API.
CALL: magentohosturl/api/rest/restapi/categories
Route section from api2.xml
<routes>
<route_entity>
<route>/restapi/categories/:cat_id</route>
<action_type>entity</action_type>
</route_entity>
<route_collection>
<route>/restapi/categories</route>
<action_type>collection</action_type>
</route_collection>
</routes>
Question: Is there something I might have overlooked that effects the route?
Full api2.xml file
<?xml version="1.0"?>
<config>
<api2>
<resource_groups>
<catalog translate="title" module="RestApi_Categories">
<title>Category Rest API extension</title>
<sort_order>10</sort_order>
</catalog>
</resource_groups>
<resources>
<categories translate="title" module="RestApi_Categories">
<group>category</group>
<model>categories/api2_categories</model>
<title>Categories retrieval</title>
<sort_order>10</sort_order>
<privileges>
<admin>
<retrieve>1</retrieve>
<!-- <create>1</create>
<update>1</update>
<delete>1</delete> -->
</admin>
</privileges>
<attributes translate="entity_id name parent_id child_id is_active level position" module="RestApi_Categories">
<entity_id>Category ID</entity_id>
<name>Name</name>
<parent_id>Category Parent ID</parent_id>
<child_id>Category Child List</child_id>
<is_active>Active</is_active>
<level>Level</level>
<position>Position</position>
</attributes>
<routes>
<route_entity>
<route>/restapi/categories/:cat_id</route>
<action_type>entity</action_type>
</route_entity>
<route_collection>
<route>/restapi/categories</route>
<action_type>collection</action_type>
</route_collection>
</routes>
<versions>1</versions>
</categories>
</resources>
</api2>
</config>
QUESTION: How do I check wether the file is loaded or not?
Filepath: \app\code\community\RestApi\Categories\etc
Followed this guide to enable developer debug mode. http://www.blog.magepsycho.com/configuring-magento-for-development-debug-mode/
Routes from Api2 files is loaded here in function getRoutes($apiType): \app\code\core\Mage\Api2\Model\Config.php
Exception log contains an error message if my api2.xml is manpulated to fail.
Errors message is also present in returned answer from Magento API, so I can confirm my api2.xml is loaded and validates, but the contained routes inside, must be wrong.
Since I've found the routes function I should be able to debug what happens.
routes
look ok to me. are you sure yourapi2.xml
is loaded? Or maybe it's not valid.