API Client Code - cURL Example

The following example shows authentication using curl commands. Anybody who needs to make API calls to fetch and update data into their microsite through HTTP calls can refer these.

  1. Setup initial call to get SESSION_ID . This curl request will store response cookies in cookies.txt

  curl  --cookie-jar cookies.txt https://<microsite-url>/oltpublish/site/connect.do

       2. Authenticate with  api_username and password. Pass in the SESSION_ID cookie returned in #1. In below 

curl -b cookies.txt --cookie-jar authenticated.txt  --data "username=<api_username>&password=<password>" https://<microsite-url>/oltpublish/site/index.do

       3. Sample API call to return user lists. This is authenticated API to get the list of users.  Similarly, other authenticated API calls can be made.

header REAL_UNAME with format  uname+"|"+(email != null?email:"")+"|"+(flname!=null?flname:"")

Example value for REAL_UNAME: "jdoe|jdoe@edubrite.com|John Doe"

If you don't want to pass email and fullname, you can simply use user name


curl -b authenticated.txt  --header "REAL_UNAME:jdoe"  https://<microsite-url>/oltpublish/site/userService.do?dispatch=list

Creating user session in browser

To create user session using API, and bypassing the signin page of lms you can use the createSessionAPI. E.g.

curl -b authenticated.txt  --header "REAL_UNAME:jdoe"  https://<microsite-url>/oltpublish/site/signinService.do?dispatch=createSessionApi

Sample response you will get upon successful call

<response code="0">

Once you have the SessionId and SessionInfo, you can open the browser with below url and lms will recognize you as a valid signed in user jdoe.


https://<microsite-url>/oltpublish/site/index.do?sessionId=<replace session-id>&sInfo=<replace session-info>