Reputation: 1
I am unclear on how to make any API calls to my Moodle web-server from my Node.JS LMS. I already setup the Moodle server and created the user with the correct role, but I don't know how to call it from my project. I'm currently just trying to extract course data from a course with an ID of 1 using core_course_get_contents. I am currently just working in javascript.
I tried making a fetch call from the client, but I was just met with various errors. I decided to use the server I'm working on as a proxy to get around the CORS limitations, but now I'm getting certificate errors or a bad JSON error.
Upvotes: 0
Views: 472
Reputation: 1121
You can create an API at Moodle. It calls Web-Services. To create and enable it follow these steps:
/admin/settings.php?section=webserviceprotocols
/admin/webservice/service.php?id=0
/admin/webservice/tokens.php?action=create
and attach it to Web Service
from step 2/admin/settings.php?section=externalservices
and add an external function to a needle service from step 2. You can use core Moodle external functions or create an own one.Yes, this is a quest, but you can use local_wsmanager plugin to manage Moodle Web-Services/APIs from one place.
Upvotes: 0