API: enrol user in a course

I spent a considerable amount of time trying to use an API that would enrol a user in a course.
To start with I checked this link Enrollment API Enrollment Resource — Open edX Platform APIs 0.1 documentation and it seems it is possible to view list of courses only for the authenticated user but NOT for another user - am I wrong?

Also, for many API endpoints I get {
“detail”: “Authentication credentials were not provided.”
}

although I followed all the steps to get all working properly - see the image…

Am I doing something wronglY/

Hi @mslyon

This thread might help you in resolving authentication issue.

thanks. Yes I have seent it also before but I’m not sure what exactly is API_KEY?
Is it the private key?
HTTP_X_EDX_API_KEY: PUT_YOUR_API_KEY_HERE

EDX_API_KEY can a be string key should be something like a pass phrase. Check what you have set in settings of your LMS or set it if not set. Then send same value in HTTP-X-EDX-API-KEY header when calling API.

thanks a lot but I’m still struggling…
this is what I did:

and this

but it still says
{
“detail”: “Authentication credentials were not provided.”
}

I tried also with curl but same…

any idea? what am I doing wrongly?

finally I found…posting here the way I managed to make it work…

curl https://example.com/api/enrollment/v1/enrollment?user=USERNAME -H “X-EDX-API-KEY: key_goes here”

1 Like

However, when I do the same with API bulk_enroll this does not work anymore

curl -d “auto_enroll=true&email_students=true&action=enroll&courses=course-v1:xxxx&identifiers=example@gmail.com” -X POST https://example.com/api/bulk_enroll/v1/bulk_enroll -H “X-EDX-API-KEY: cxxxx”

I get {“detail”:“Authentication credentials were not provided.”}

Any idea whis is so?

I have finally figured out what the problem was…

it is related to bitnami edx configuration of apache 2 - by adding this
WSGIPassAuthorization On

to the end of the httpd.conf, it solved the issue of authorization…