What is the meaning of error ? How to resolve webservice error?

What is the meaning of error ? How to resolve webservice error?

by Kathir Rajaraman -
Number of replies: 2

Dear all,


I have created one web service. I got the following errors ,


REST protocol: moodle_user_create_users

URL: http://localhost/moodle/webservice/rest/server.php?wstoken=0af2351e0bd4111142e59cdfc4b4ec2a
'<?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 moodle_user_create_users() 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 &gt; Site administration
&gt; Plugins &gt; Web services &gt; External services and Manage tokens.</DEBUGINFO>
</EXCEPTION>
'
How to resolve this error ?

Can you help me ?

Thanks
Kathir R



Average of ratings: -
In reply to Kathir Rajaraman

Re: What is the meaning of error ? How to resolve webservice error?

by Vijaya Laxmi -

Create external service add this function to service  core_user_create_users generate token the following code for client side 

<?php

$token = '';

$domainname = '';

$functionname = 'core_user_create_users';

$restformat = 'xml';

//array to assign user details to create user

$user1 = new stdClass();

$user1->username = 'paul'; //should be unique

$user1->password = 'Paul#5';

$user1->firstname = 'paul';

$user1->lastname = 'paul';

$user1->email = 'paul@moodle.com'; //should be unique

$user1->auth = 'manual';

$user1->idnumber = 'testidnumber1';

$user1->lang = 'en';

$user1->theme = 'standard';

$user1->timezone = '-12.5';

$user1->mailformat = 0;

$user1->description = 'Hello World!';

$user1->city = 'testcity1';

$user1->country = 'au';

$preferencename1 = 'preference1';

$preferencename2 = 'preference2';

$user1->preferences = array(

    array('type' => $preferencename1, 'value' => 'preferencevalue1'),

    array('type' => $preferencename2, 'value' => 'preferencevalue2'));

$user2 = new stdClass();

$user2->username = 'jack'; //should be unique

$user2->password = 'Jack#5';

$user2->firstname = 'jack';

$user2->lastname = 'jack';

$user2->email = 'jack@moodle.com'; //should be unique

$user2->timezone = 'Pacific/Port_Moresby';

$users = array($user1, $user2);

$params = array('users' => $users);

header('Content-Type: text/plain');

$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;

require_once('curl.php');

$curl = new curl;

$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';

$resp = $curl->post($serverurl . $restformat, $params);

print_r($resp);


In reply to Vijaya Laxmi

Re: What is the meaning of error ? How to resolve webservice error?

by Kathir Rajaraman -

Hi Vijaya,

Thanks for your reply. Really am happy. Its working fine. I have another doubt. 

1) Front page is android and backend is moodle. Moodle users login to android. Users login to android with moodle users. How to check login valid users or not ?

2) Moodle course contents send to android. I mean i create one course then i add resource file put in HTML.zip file. This HTML.zip send to android. How ? 

Can you help me ?


Thanks 

Kathir R