Web services

Using enrol_manual_enrol_users via XML-RPC.NET

Picture of Mike Z
Using enrol_manual_enrol_users via XML-RPC.NET

Hello all,

I need your help with consuming the webservice:  enrol_manual_enrol_users

My client app is in ASP.NET, and I am using the XML-RPC.NET library to make XML-RPC calls to Moodle.  

I should note that I am able to successfully call the web service "core_user_get_users_by_id".  However that is a simple case. It takes an Int array as the parameter and returns an object array containing hashtables, one per user record, and with each key-value pair representing a field from the user table.

However for enrol_manual_enrol_users, I can't figure out how I should code the Method call or handle the return object.  Indeed, from the Moodle documentation, there is nothing listed under the "Response" heading for this method.

Here is what I currently have, but this is giving me a rather useless "[404] Unknown error" as the response from Moodle.  I expect the problem is because I don't really understand how to use the Struct in the method call, or how to obtain the result from Moodle's response.


Here is the interface definition

public interface IMoodle : IXmlRpcProxy {

object[] Enrol_Manual_Enrol_Users(Moodle_Enrolment[] input);      //Not sure if it should be delcared as object[] or not, as there is no Response described in the Moodle docs.



And the Struct that should represent the input parameter for the webservice

    public struct Moodle_Enrolment
        public int roleid;
        public int userid;
        public int courseid;
        public int timestart;
        public int timeend;
        public int suspend;


And here is the code that instantiates the struct, and calls the WebMethod.

           Moodle_Enrolment me = new Moodle_Enrolment();

            me.courseid = 2  //this defiinately exists in the Moodle database
            me.userid = 7;    //this defiinately exists in the Moodle database
            me.roleid = 1;   
            Moodle_Enrolment[] meArray = {me};       //Put the enrolment details into an array.

                object[] a = moodleServer.Enrol_Manual_Enrol_Users(meArray);    //not sure what the response datatype is
            catch  (Exception ex)

                   //Error handling code goes here


When this code runs, an exception occurs on the call to Moodle, and the exception message is:

Server returned a fault exception: [404] Unknown error


So - can you offer any suggestions on how to fix this?  I am sure I am doing something wrong here - but the documentation on the webservice enrol_manual_enrol_users is really not helping me much.    

Unfortunately this web service is not available in the Moodle test client.  Any suggestions on how I can find out about this 404 Unknown Error?


Thanks for your help all,




Average of ratings: -
Picture of Jordi Barajas Gines
Re: Using enrol_manual_enrol_users via XML-RPC.NET

Hi Did you solve your problem?

Average of ratings: -
Picture of Supriya Seetharam
Re: Using enrol_manual_enrol_users via XML-RPC.NET

HI ,

I am Novice to XML RPC Moodle integration. I am developing a c# application

Below is the code i am working with

public interface IMoodle : IXmlRpcProxy



        object[] GetUserById(object[] id);


        object[] GetCourses();



----Main Program----------------------

          IMoodle moodleProxy;

            moodleProxy = XmlRpcProxyGen.Create<IMoodle>();

            moodleProxy.Url = "http://localhost/" + "webservice/xmlrpc/server.php?wstoken=" + "wsusertoken";

         object[] a = moodleProxy.GetCourses();


I am getting "Server returned a fault exception: [404] Unknown error" exception. I am not sure where am i missing. Any help will be commendable.



Average of ratings: -