How do I remove a user from a SECTION using the API

Brendon.I.8672
Brendon.I.8672 Posts: 3 🔍
edited December 16 in Higher Ed / Postsecondary

I am able to enroll a user into any given section using the API, however I am unable to remove that same user from any given section using the API. I've reviewed the various endpoints, and the closest I got to removing a user using the API from a section was to call the DELETE method on an endpoint like this:

$API_ROOT/lp/$version/enrollments/users/$D2LUserId/orgunits/$orgUnitID

This however removes the user from the course (and subsequently all sections) however if they're re-enrolled in the course, they return to their previous sections.

If there is an API endpoint I over looked, or if their is a method to move a user from one section to another, this would be very helpful.

I am able to un-enroll a user from a section using the Web page administration, which led me to think it maybe had to do with the groups and group categories deletion endpoint but this ended up not being the case

Tagged:

Best Answer

  • Ajith.J.824
    Ajith.J.824 Posts: 11
    Answer ✓

    Hi @Brendon.I.8672,

    Thank you for the question. You should be able to remove a user from a section using this API endpoint-
    DELETE /d2l/api/lp/(version)/enrollments/orgUnits/(orgUnitId)/users/(userId)

    I hope this helps.

Answers

  • Brendon.I.8672
    Brendon.I.8672 Posts: 3 🔍
    edited December 16

    Thank you very much Ajith.J.824

    You were spot on. I had tried this call prior, passing the course ID (orgUnitID) as the OrgUnitID. I never thought to pass the Section ID instead. Doing that worked perfectly. So obvious looking back at it now.

    I guess for users in the future, if you want to remove a user from a section, try thinking like this:

    DELETE /d2l/api/lp/(version)/enrollments/orgUnits/(SectionUnitId)/users/(userId)

    Thanks again!