3

For one of my projects I need to manage some of the attributes of our Moodle, including (but probably not limited to) Creating/Updating users and managing enrolments.

I need to create this interface in a .Net (4.0+) Console application, so information can be processed from other systems.

I have checked NuGet for packages for Moodle but I cant find anything.

Can you advise on how I could achieve this interface?

Thanks in advance.

Si Blight
  • 109
  • 1
  • 13

2 Answers2

2

I don't think there is a wrapper available for this. You will need to enable moodle webservices:

https://docs.moodle.org/dev/Web_services

And create your own. I am using RestSharp for this:

https://www.nuget.org/packages/RestSharp

lng
  • 805
  • 1
  • 11
  • 31
0

This code will work for accessing course information

 string result = "";
            string methodName = "GetCourse";                  
            string apiName = "core_course_get_courses";           
            string apiCall = moodleUrl + "?wstoken=" + token + "&wsfunction=" + apiName + "&moodlewsrestformat=json";

            try
            {
                using (WebClient client = new WebClient())
                {
                    client.BaseAddress = apiCall;
                    client.Headers[HttpRequestHeader.Accept] = "application/json";
                    result = client.DownloadString(apiCall);
Paul
  • 1
  • 4