I can't seem to figure this one out.
The class:
class Assets {
function getOne($id) {
$asset = DBO_Asset::getOneByPublicId($id);
return $asset->id;
}
}
The index.php:
require_once 'restler/restler.php';
require_once 'API/Assets.php';
$rest = new Restler();
$rest->addAPIClass("Assets");
$rest->handle();
The URL:
http://localhost/api/index.php/assets/getOne/8TWVTZAU
The result:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
I have no idea why this is creating a 404, but I followed the instructions, and I am still not getting anywhere. Can someone please help me figure this out?
Restler is using get
, post
, put
, delete
as method prefixes to automatically map them to respective HTTP method/verb
GET is the default HTTP method, so if you dont prefix a method with any of the above, it will be mapped to GET method
Your api is currently mapping to the following url
http://localhost/api/index.php/assets/one/8TWVTZAU
If having getOne
in the url is important for you, use @url
comment as shown below to manually route that way
class Assets
{
/**
* @url GET getOne/:id
* @url GET getOne
*/
function getOne($id)
{
$asset = DBO_Asset::getOneByPublicId($id);
return $asset->id;
}
}