How to use this function core_course_get_courses ? When i use this function core_course_get_courses what the requirement ? we need enable webservice ? Then any other requirement ?
the following php client side code working for me
$token = '';
$domainname = '';
$functionname = 'core_course_get_courses';
$restformat = 'xml';
$params = array();
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;
$curl = new curl;
$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';
$resp = $curl->post($serverurl . $restformat, $params);
Thanks for your reply. I had copy and past your code but not working me. I got some error
<?xml version="1.0" encoding="UTF-8" ?> <EXCEPTION class="webservice_access_exception"> <ERRORCODE>accessexception</ERRORCODE> <MESSAGE>Access control exception</MESSAGE> <DEBUGINFO>Access to the function core_course_get_courses() is not allowed. There could be multiple reasons for this: 1. The service linked to the user token does not contain the function. 2. The service is user-restricted and the user is not listed. 3. The service is IP-restricted and the user IP is not listed. 4. The service is time-restricted and the time has expired. 5. The token is time-restricted and the time has expired. 6. The service requires a specific capability which the user does not have. 7. The function is called with username/password (no user token is sent) and none of the services has the function to allow the user. These settings can be found in Administration > Site administration > Plugins > Web services > External services and Manage tokens.</DEBUGINFO> </EXCEPTION>
How to resolve the issue ? Then another doubt how to check webservice running or not in our local machine moodle setup ?
Thanks & Regards
Thanks for your reply. I will check here.
First you check whether you added this function to service or not. later check the token generation.then it will work.
Thanks for your reply. Function is added vijaya.
Below the following steps am using
Development -> Web service test client - > Page Open
Authentication method -> token
Finally i click submit button
<MESSAGE>Access control exception</MESSAGE>
I think your user with this token doesn't have rights to use REST Protocol, check this.
Thanks for your reply. How to check my user token rights to REST Protocol ?
Go to Site administration > Users > Permissions > Define roles then select the role of your users which the token is connected to, edit it and go to the permission called "Use REST protocol" and check it.
Now it should be working if it's not, edit your external webservice and select "Use REST protocol" in "Required capability"