User Enrollment in Custom Org Unit Type

Nick.H.7224
Nick.H.7224 Posts: 3 🌱

I am able to enroll a user into a standard org unit type with a role just fine, but when I attempt to enroll them in a custom org unit type, labeled Campus, I receive a 403: Unauthorized response code.

The granted scope contains the scope listed for the POST /d2l/api/lp/(version)/enrollments/ endpoint.

I've also confirmed the role applied to the integration account does support enrolling the role into the Campus org unit type.

image.png

Does the enrollments API support enrolling a user into custom org unit types? If so, what other permission(s) may need to be enabled?

Comments

  • Justin.B.253
    Justin.B.253 Posts: 59 🧭

    @Nick.H.7224 Nick, are you asking if its possible to enroll a user via API into a non-academic or sandbox course in a custom org unit type? Or directly into the Org Unit Type? What does your Org structure look like. We have ORG > Discipline/Department > Course Template > Course Offering. In Course Offerings, you can have sections and groups. What is your Admin level?

    Have you used the OrgStructure API to get the ID number for that custom org unit? https://{org}/d2l/api/lp/{version}/orgstructure/

    The enrollment should be the same for enrolling into a standard org unit.

    POST /d2l/api/lp/(version)/enrollments/
    {
    "OrgUnitId": 123456, // ID of the custom org unit (Group, Department, etc.)
    "UserId": 78910, // Brightspace internal UserId (not OrgDefinedId)
    "RoleId": 101 // RoleId applicable to that OrgUnitType
    }

  • Nick.H.7224
    Nick.H.7224 Posts: 3 🌱

    Hello @Justin.B.253,

    No, I'm not having any issue enrolling the user in a course. When attempting to enroll them in a different org unit type, called Campus in this case, that's where I receive the 403: Unauthorized response code.

    The Org Structure is as follows:
    Org > Department / Campus > Course Template > Course Offering

    Campus sits as a child of the primary org unit, a sibling to department, and has another child org unit type, curriculum.

    I did test using the orgstructure API and got a successful response using the IDs of the campus org units.

    Between the enrollment for the "standard" org unit, being a course offering in this case and the attempt to enroll the user into the Campus, the only thing that changes in the request body is the OrgUnitId. The URI is also unchanged.

    The role that I'm assigning is valid for both org units, and I am even able to successfully add the user to the Campus' classlist in the UI but get the 403 response via API. This is done using the same user, so permissions should be the same, and I believe I have the correct oauth scope included, otherwise the course offering enrollment should fail as well.

  • Justin.B.253
    Justin.B.253 Posts: 59 🧭

    Ok, thank you for that clarity, we have Assistant Deans that I manually enroll into the Departments they oversee and have been successful at enrolling through the UI as well, I haven't done one through API, but I'll give it a shot and report back.

  • Justin.B.253
    Justin.B.253 Posts: 59 🧭

    @Nick.H.7224 I was able to successfully enroll one of our AD's into a Department level for a cascading role with Postman. I'm using an older version number, but I don't think that's your issue. Are you following this structure below? And are you using UserId and NOT OrgDefinedId? How are you using API's? Have you build a widget or html page that does process or are you running them through Postman or another software? If you are following the same process as outlined here, then it might be something in your permissions but that would be odd if you have the permission to manually enroll in the UI.

    image.png