How to use the enrollment API

303 views
Skip to first unread message

Emmanuel Jaep

unread,
Oct 31, 2018, 10:12:26 AM10/31/18
to Open edX operations
Hi,

I'm trying to use the enrollment APIs from an external application.

When I perform a simple HTTP get to the endpoint, I get a 401 error:
curl -v https://myinstall.mydomain.com


returns:
...
< HTTP/1.1 401 UNAUTHORIZED
...
{"detail":"Authentication credentials were not provided."}%


Unfortunately, I could not find any documentation on how to authenticate, generate the access tokens...

Would someone have a quick example on the full process (from the first call to getting data from the endpoint)?

Based on this, I'll be really happy to put together a complete documentation for others.

cheers,

Emmanuel

Nate Aune

unread,
Oct 31, 2018, 12:57:19 PM10/31/18
to opene...@googlegroups.com
Here are our docs for using the enrollment API which may differ slightly from Hawthorn master, as we have our own fork and extended the API with some additional features for programmatically issuing bulk enrollment codes.

Here's a step by step guide to creating an OAuth user in devstack

You might also find this useful for testing purposes:



--
You received this message because you are subscribed to the Google Groups "Open edX operations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openedx-ops/556dcdcd-e40b-410e-ac44-95e1e5ec189b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


stv stnfrd

unread,
Oct 31, 2018, 6:33:40 PM10/31/18
to Open edX operations
Thanks for sharing, Nate!

As it turns out, at Stanford we've also built out some of this
functionality on our own fork. Specifically, we've extended the existing
enrollment API to provide a "roster" endpoint which allows a course
roster to be viewed and updated.

We've accomplished this with a single endpoint [1]
that exposes 3 HTTP methods:
- GET: retrieve a list of all users enrolled in a course [2]
- PUT: enroll a user in a course [3]
- DELETE: unenroll a user from a course [4]

Note: The logic for enroll/unenroll is identical to that used by the
existing Bulk Enroll tool on the instructor dashboard.

-- Steven at Stanford


References:
- [1] https://github.com/Stanford-Online/edx-platform/blob/master/openedx/stanford/common/djangoapps/enrollment/views.py
- [2] GET /api/enrollment/v1/roster/course-v1:foo+bar+foobar
- [3] PUT /api/enrollment/v1/roster/course-v1:foo+bar+foobar
      {
          'email': 'f...@bar.com',
          'email_students': false,
          'auto_enroll': true,
      }
- [4] DELETE /api/enrollment/v1/roster/course-v1:foo+bar+foobar
      {
          'email': 'f...@bar.com',
      }

Emmanuel Jaep

unread,
Nov 1, 2018, 10:44:11 AM11/1/18
to Open edX operations
Hi Nate,

thanks for the pointers, it allowed me to get started.
I also created a gist putting together the first steps to get started. I hope it'll help others to get started: https://gist.github.com/jaepetto/2ba4e775f147455fbb963f61e64b7288

Best,

Emmanuel

Nate Aune

unread,
Nov 1, 2018, 4:23:56 PM11/1/18
to Open edX operations
Thanks Emmanuel for sharing your notes!  It seems the images in the actual markdown "how-to.md" are not loading for some reason.

Emmanuel Jaep

unread,
Nov 1, 2018, 4:27:56 PM11/1/18
to opene...@googlegroups.com

My pleasure. I will transform the gist into a GitHub repo. I just figured out that:

  • If I upload the images with the md file, they appear on top of the file list (hence hiding the document)
  • Gists do not support sub-folders

 

I’ll update my question on the group so people can have a reference.

--
You received this message because you are subscribed to a topic in the Google Groups "Open edX operations" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openedx-ops/oO128Ag_jeE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openedx-ops...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openedx-ops/30879aef-0a03-444e-a375-6ebcaea33e34%40googlegroups.com.

Emmanuel Jaep

unread,
Nov 1, 2018, 5:05:03 PM11/1/18
to Open edX operations
Hi Nate,

I think it will be much more readable and easy to use on the GitHub repository: https://github.com/jaepetto/POC_edX_APIs

Cheers,

Emmanuel

Rui Pinto

unread,
Jan 8, 2019, 9:12:35 AM1/8/19
to Open edX operations
Hi Nate!

We have already got "appsembler_api" from github and placed it in proper place in our local open-edx install (under "edx-platform/lms/djangoapps/").
However, we are not being able to access it.

Could you help us on what configurations are needed?
We would like to access "<base_url>/appsembler_api/v0/analytics/accounts/batch" (for instance) like we access to "<base_url>/api/user/v1/accounts".
We are getting a "Page not found"...

Thanks in advance!


Best regards.

Nate Aune

unread,
Jan 8, 2019, 4:58:38 PM1/8/19
to opene...@googlegroups.com
You might Need to add this appsembler_api app to the urls.py.


For more options, visit https://groups.google.com/d/optout.
--

Rui Pinto

unread,
Jan 9, 2019, 10:16:17 AM1/9/19
to opene...@googlegroups.com
Nate,

First of all, thank you for your tip!

We added "url(r'^appsembler_api/', include('lms.djangoapps.appsembler_api.urls'))," to the file "/edx/app/edxapp/edx-platform/lms/urls.py".

However, the API is still unavailable, and the logs show:

_import__(name)
    File "/edx/app/edxapp/edx-platform/lms/urls.py", line 113, in <module>
        url(r'^appsembler_api/', include('lms.djangoapps.appsembler_api.urls')),
    File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
        urlconf_module = import_module(urlconf_module)
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
    ImportError: No module named appsembler_api.urls 

 
Do you know what configuration is missing?  

Thanks again!


Rui Pinto

unread,
Jan 23, 2019, 11:34:01 AM1/23/19
to Open edX operations
Hi Nate,

Can you please help us out on this?

Thanks!


Best regards.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops+unsubscribe@googlegroups.com.
--

--
You received this message because you are subscribed to the Google Groups "Open edX operations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops+unsubscribe@googlegroups.com.

Nate Aune

unread,
Jan 26, 2019, 6:37:06 PM1/26/19
to opene...@googlegroups.com
You need to add these lines in lms/urls.py


url(r'^api/enrollment/v1/'''enrollment.urls, include()),
url(r'^appsembler_api/v0/'''appsembler_api.urls, include()),




For more options, visit https://groups.google.com/d/optout.

Rui Pinto

unread,
Jan 28, 2019, 9:09:13 AM1/28/19
to Open edX operations
Hi, Nate.

Thanks for your help!

We did the changes, but now we get "Import error: No module named appsembler_api.urls".

In attachments, we send some printscreens from our system. Can you please determine what is wrong?


Thanks!


Best regards.
--

--
You received this message because you are subscribed to the Google Groups "Open edX operations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Open edX operations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openedx-ops/330b25ee-34f7-46f8-87c4-a13ba1176854%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
tree.jpg
edited_file.jpg
error.jpg

Nate Aune

unread,
Jan 28, 2019, 9:27:00 AM1/28/19
to opene...@googlegroups.com

Rui Pinto

unread,
Jan 28, 2019, 1:09:07 PM1/28/19
to Open edX operations
We added the lines, but still the same error.

We send you new printscreens of "common.py" and "urls.py" with the lines inserted, to see if you can detect something wrong or missing.

Thanks again!
common.py.jpg
1_urls.py.jpg
2_urls.py.jpg
Reply all
Reply to author
Forward
0 new messages