I would like to enroll and unenroll students programmatically, outside the user interface. I thought of a manage.py command, or an exposed API. Do you know if it is implemented?
You can use the above POST API endpoint to enroll multiple users in one or more courses and the same can be used for unenrollment. You have to enable
ENABLE_BULK_ENROLLMENT_VIEW this feature flag in order to make the above API endpoint available in Open edX.
Now, I was able to get a JWT token, however when I try to make a request I get a 500 error and the following log tail:
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/edx_rest_framework_extensions/auth/jwt/decoder.py", line 189, in _get_signing_jwk_key_set key_set.load_jwks(signing_jwk_set) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/jwkest/jwk.py", line 776, in load_jwks self.load_dict(json.loads(jwks)) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded
I am doing this to test:
curl -X GET -H "Authorization: JWT eyJhbG.........LmNvbSJ9" https://my.lms/api/bulk_enroll/v1/bulk_enroll/
(When I do a complete request with data from python I get the same 500 error)
I was following this instructions to make the call.
Any idea what I may be doing wrong?
I don’t have any idea about your error but some pointers.
Usually, I don’t try
curl to test APIs, instead of it I test the APIs in the Postman.
In the Postman, I was able to call this bulk enrollment API successfully. One thing I did was that I have passed parameters (
auto_enroll, email_students, action, courses, identifiers) in the body of the request as form-data inside Postman.
And I have tested this with the OAuth2 token instead of the JWT token.
One last thing is that this API endpoint is POST not GET.