Magento rest api getting error Request does not match any route
<p>I have created a rest api web service but I am getting error on hitting the url </p>

<p><a href="http://localhost:81/magento/api/rest/category/2" rel="nofollow">http://localhost:81/magento/api/rest/category/2</a></p>

<pre><code>&lt;magento_api&gt;
    &lt;messages&gt;
        &lt;error&gt;
            &lt;data_item&gt;
                &lt;code&gt;404&lt;/code&gt;
                &lt;message&gt;Request does not match any route.&lt;/message&gt;
            &lt;/data_item&gt;
        &lt;/error&gt;
    &lt;/messages&gt;
&lt;/magento_api&gt;
</code></pre>

<p><strong>My api2.xml is:-</strong></p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;config&gt;
    &lt;api2&gt;
        &lt;resource_groups&gt;
            &lt;esoft_rescategories translate="title" module="Esoft_Restcategories"&gt;
                &lt;title&gt;Esoft Restcategories API&lt;/title&gt;
                &lt;sort_order&gt;11&lt;/sort_order&gt;
            &lt;/esoft_rescategories&gt;
        &lt;/resource_groups&gt;
        &lt;resources&gt;
            &lt;esoft_restcategories translate="title" module="Esoft_Restcategories"&gt;
                &lt;group&gt;esoft_rescategories&lt;/group&gt;
                &lt;model&gt;esoft_restcategories/api2_restapi&lt;/model&gt;
                &lt;title&gt;Categories&lt;/title&gt;
                &lt;sort_order&gt;11&lt;/sort_order&gt;
                &lt;privileges&gt;
                    &lt;admin&gt;
                        &lt;create&gt;1&lt;/create&gt;
                        &lt;!--&lt;retrieve&gt;1&lt;/retrieve&gt;
                        &lt;update&gt;1&lt;/update&gt;
                        &lt;delete&gt;1&lt;/delete&gt;--&gt;
                    &lt;/admin&gt;
                    &lt;guest&gt;
                        &lt;retrieve&gt;1&lt;/retrieve&gt;
                        &lt;!--&lt;create&gt;1&lt;/create&gt;
                        &lt;update&gt;1&lt;/update&gt;
                        &lt;delete&gt;1&lt;/delete&gt;--&gt;
                    &lt;/guest&gt;
                &lt;/privileges&gt;
                 &lt;attributes&gt;
                &lt;category_id&gt;Category ID&lt;/category_id&gt;
                &lt;name&gt;Name&lt;/name&gt;
                &lt;parent_id&gt;Category Parent ID&lt;/parent_id&gt;
                &lt;child_id&gt;Category Child List&lt;/child_id&gt;
                &lt;active&gt;Active&lt;/active&gt;
                &lt;level&gt;Level&lt;/level&gt;
                &lt;position&gt;Position&lt;/position&gt;
            &lt;/attributes&gt;
             &lt;routes&gt;
               &lt;route_entity&gt;
                        &lt;route&gt;/categories/:cat_id&lt;/route&gt;
                        &lt;action_type&gt;entity&lt;/action_type&gt;
                    &lt;/route_entity&gt;
                    &lt;route_collection&gt;
                        &lt;route&gt;/categories&lt;/route&gt;
                        &lt;action_type&gt;collection&lt;/action_type&gt;
                    &lt;/route_collection&gt;
            &lt;/routes&gt;
                &lt;versions&gt;1&lt;/versions&gt;
            &lt;/esoft_restcategories&gt;
        &lt;/resources&gt;
    &lt;/api2&gt;
&lt;/config&gt;
</code></pre>

<p><strong>My version file for guest is:-</strong></p>

<pre><code>&lt;?php

class Esoft_Restcategories_Model_Api2_Restapi_Rest_Guest_V1 extends Esoft_Restapi_Model_Api2_Restapi {

  /**
 * Retrieve list of category list.
 *
 * @return array
 */
protected function _retrieveCollection()
{   
    $ruleId = $this-&gt;getRequest()-&gt;getParam('cat_id');

//  $cat_mod = Mage::getModel('catalog/category')-&gt;load($ruleId)-&gt;toArray();
    $cats = Mage::getModel('catalog/category')-&gt;load($ruleId);
    $subcats  = Mage::getModel('catalog/category')-&gt;load($ruleId)-&gt;getChildren();

    $cur_category = array();

    $node['category_id'] = $ruleId;
    $node['name'] = $cats-&gt;getName();
    $node['parent_id'] = $cats-&gt;getParentId();
    $node['child_id'] = $subcats;
    if($cats-&gt;getIsActive()){
        $node['active'] = 1;
    }else{
        $node['active'] = 0;
    }
    $node['level'] = $cats-&gt;getLevel();
    $node['position'] = $cats-&gt;getPosition();

    $cur_category[] = $node;

//  $subcats  = Mage::getModel('catalog/category')-&gt;load($ruleId)-&gt;getAllChildren();
//  $subcats  = Mage::getModel('catalog/category')-&gt;load($ruleId)-&gt;getChildren();

    if($subcats != '') 
    {
        foreach(explode(',',$subcats) as $subCatid)
        {
            $_category = Mage::getModel('catalog/category')-&gt;load($subCatid);
            $childcats  = Mage::getModel('catalog/category')-&gt;load($subCatid)-&gt;getChildren();

            $node['category_id'] = $subCatid;
            $node['name'] = $_category-&gt;getName();
            $node['parent_id'] = $_category-&gt;getParentId();
            $node['child_id'] = $childcats;
            if($_category-&gt;getIsActive()){
                $node['active'] = 1;
            }else{
                $node['active'] = 0;
            }
            $node['level'] = $_category-&gt;getLevel();
            $node['position'] = $_category-&gt;getPosition();

            $cur_category[] = $node;

        }
    }

    return $cur_category;       
}
}
</code></pre>

<p>Please let me know how to fix this error.</p>

<p>Also let me know on what basis we define routes.</p>