How to update the user enrolment via the API

How to update the user enrolment via the API

by Carlos Chiarella -
Number of replies: 2

Hi,

We are using Moodle version 383 and we are trying to update the user enrolment date (start and end dates). We are trying to use core_enrol_submit_user_enrolment_form. If I looked in the documentation, it only says:

"Submit form data for enrolment form"  

It does not specify which fields to pass. We calling the function like this:

https://lms.rcmstg.com/lms/webservice/rest/server.php?moodlewsrestformat=json&wstoken=rcmtoken&wsfunction=core_enrol_submit_user_enrolment_form&formdata={"ue":"66422","ifilter":"0","status":"0","timestart":"1610480371","timestart":"1642092064"}

But it returns this error:

{"exception":"dml_missing_record_exception","errorcode":"invalidrecord",
"message":"Can't find data record in database table user_enrolments. (SELECT * FROM {user_enrolments} WHERE id IS NULL\n[array (\n)])",
"debuginfo":"SELECT * FROM {user_enrolments} WHERE id IS NULL\n[array (\n)]"}

The "ue" value is correct. What are we doing wrong?

Can somebody please help us? Thanks, Carlos Chiarella
Average of ratings: -
In reply to Carlos Chiarella

Re: How to update the user enrolment via the API

by Vitor Carvalho -
Hi Carlos Chiarella,

Have you found the solution for this error?

I am trying to use this function, but I don't understand the parameters required.

I want to know which parameters are required since to Moodle source code says it is required the 'formdata'.

Regards, Vitor Carvalho
In reply to Vitor Carvalho

Re: How to update the user enrolment via the API

by Carlos Chiarella -
Hi Vitor,
Sorry for my ate answer. We had to create another function that works.

Carlos