by Charan Sri.
Hello All,
I am trying to write a custom web service in Moodle. I took local_wstemplates_hello_world as an example and trying to implement a webservice for my custom plugin.
I have added three methods as below in externallib.php file:
1) function coupons_parameters()
2) function coupons()
3) function coupons_returns()
In Services.php file. I have added code as below:
$services = array(
'My service' => array(
'functions' => array ('local_wstemplate_hello_world', 'local_wstemplate_coupons'),
'restrictedusers' => 0,
'enabled'=>1,
)
);
$functions = array(
'local_wstemplate_hello_world' => array(
'classname' => 'local_wstemplate_external',
'methodname' => 'hello_world',
'classpath' => 'local/wstemplate/externallib.php',
'description' => 'Return Hello World FIRSTNAME. Can change the text (Hello World) sending a new text as parameter',
'type' => 'read',
),
'local_wstemplate_coupons' => array(
'classname' => 'local_wstemplate_external',
'methodname' => 'coupons',
'classpath' => 'local/wstemplate/externallib.php',
'description' => 'Return coupons details',
'type' => 'read'
)
);
Now, When I want to call the method 'coupons()' from a webservice using wsfunction = local_wstemplate_coupons.
It is showing error as follows:
stdClass Object ( [exception] => dml_missing_record_exception [errorcode] => invalidrecord [message] => Can not find data record in database table external_functions. [debuginfo] => SELECT * FROM {external_functions} WHERE name = ? [array ( 0 => 'local_wstemplate_coupons', )] )
Please help me on how to fix this issue?
Thanks in Advance
Regards
Sricharan