Initialize API Connection
All API Communications are authenticated through two session cookies that need to be sent in each API call to the site by the client making the communication.
- SESSION_ID - contains randomly assigned id for the current session
- SESSION_INFO - contains authenticated token
The cookies once obtained from the site are held by the client during the entire duration of the current session. These cookies are obtained by making an initial call to the site (as shown in the code snippet below) by sending the API username and password in the request parameters.
To get the first cookie (SESSION_ID)
Send a HTTP request to URL http://yoursite.edubrite.com/oltpublish/site/connect.do
No parameters need to be sent (they are ignored)
To get the second cookie (SESSION_INFO)
Send a HTTP request to URL http://yoursite.edubrite.com/oltpublish/site/connect.do with SESSION_ID cookie (in the header) and following parameters
- username - this should be set to api username
- password - this should be set to api password
If the authentication is successful, you will be able to get SESSION_INFO cookie from the response headers. Once you have these two cookies, you must save them (in variables) and set them in all subsequent requests. Do not create new session for each API calls (there is a throttling limit placed on number of API sessions per microsite).
Check the API Setup document to know more about how to enable integration in the microsite and obtain the API UserName and password.
A reference implementation of a client library in java is available for reference. All references from the code snippets are made to this library. To check PHP reference look up here
Code Snippet
Call to Connect and Obtain Cookies
The following code snippet would make the initial connections to the site and receive the two set of cookies using API username/password authentication. On successful connect (as indicated by the success flag), the client should keep holding the Connection object throughout their entire API session. Connection object internally stores the two cookies. This Connection object can then be used to make all the API calls.
ConnectionConfig config = ConnectionConfigManager.getInstance().getConnectionConfig();
Connection connection = new Connection(config);
boolean success = connection.connect();
if (success) {
String sessionId = connection.getSessionId();
String sessionInfo = connection.getSessionInfo();
} else {
CommunicationError error = connection.getLastError();
}
String responseXml = connection.getLastResponseXml();
int httpCode = connection.getLastHTTPCode();
Disconnect and Release Cookies
Before ending the API session, simply call the disconnect method on the Connection object which was obtained during the initial call as shown above. No API call would be successful on the Connection object once the disconnect method has been called.
connection.disconnect();
Response
1. Correct combination of username and password specified
HTTP Response Code = HttpServletResponse.SC_OK
Response XML
<response code="0">
<msgs>
<msg>
<code>0152</code>
<value><![CDATA[API Connection Successful]]></value>
</msg>
</msgs>
</response>
2. Invalid username/password combination specified
HTTP Response Code = HttpServletResponse.SC_UNAUTHORIZED
Response XML
<response code="-1">
<msgs>
<msg>
<code>0014</code>
<value><![CDATA[Invalid username or password.]]></value>
</msg>
<msg>
<code>0154</code>
<value><![CDATA[API Connection Not Successful]]></value>
</msg>
</msgs>
</response>
Related Pages
Group Management
Javascript
- Customization On Payment Page
- Validate IP Address while accessing the course
- UI Customization JavaScript Functions
- Verify Custom properties during Test Taking
- Verifying User Properties During Test
- JS Example
- example_custom_scripts
- Test Taking - Customization using callback mechanism
- Cms Calendar Example
Reports
Enrollment Management
- API - Update Event Subscription
- API - Create ExamTestInstance
- Update Program Member - via Program Session Id
- Update Program Member
- API - Self Enroll in Course Session
- Update Course Session Member
- API - Self Enroll in Program Session
- API - Self Enroll in Event
- API - Enroll Users in Course Session
- API - Enroll Users in Program Session
- API - Enroll Users in Event
- API - Enroll Users in Program
Other
Introduction
Report
- Get Sites Metadata
- Get Open Learning Items List
- API - Program Enrollment Summary
- API - Course Enrollment Summary
- Get Catalog Items List
- API - Course Session Members list
- API - Program Members List
- Event participants list
- Api - Test Attempts (Test Instances) List
- Test instance details list
- Api - Non Subscribed Event List
- Api - Subscribed Event List
- API - List All Report Schedules
- API - Get Latest Report Content For A Given Schedule ID
- API - Get Report Content For A Given Report ID
- API - List Reports For A Given Schedule
User Management
- API - User list
- API - Get user details
- Api - User Creation
- API - Create User (With Custom Properties)
- API - Update User
- API - Rename User
- API - Add user to group(s)
- API - Remove user from group(s)
- Merge User Accounts
- API - Activate User
- API - Deactivate User
- API - Change User's Origin Site
- Api - User Login (Creating User Session)
eCommerce
API Documentation
Examples
- User Creation
- User Update
- User List
- Get User Details
- Add User to Group(s)
- Remove User from Group(s)
- User Activate
- User Deactivate
- User Login
- Group List
- Group Membership
- Course Subscription(Coupon Code)
- Subscribed Events List
- Non Subscribed Events List
- Test Instances in Microsite
- Forum APIs
- Javascript Example
Client Example
Quick Links
- Home
- Getting Started
- Knowledgebase
- Video Tutorials
- Google Apps Integration
- Gilly (Plugin for Atlassian Confluence)
Group Management
Javascript
- Customization On Payment Page
- Validate IP Address while accessing the course
- UI Customization JavaScript Functions
- Verify Custom properties during Test Taking
- Verifying User Properties During Test
- JS Example
- example_custom_scripts
- Test Taking - Customization using callback mechanism
- Cms Calendar Example
Reports
Enrollment Management
- API - Update Event Subscription
- API - Create ExamTestInstance
- Update Program Member - via Program Session Id
- Update Program Member
- API - Self Enroll in Course Session
- Update Course Session Member
- API - Self Enroll in Program Session
- API - Self Enroll in Event
- API - Enroll Users in Course Session
- API - Enroll Users in Program Session
- API - Enroll Users in Event
- API - Enroll Users in Program
Other
Introduction
Report
- Get Sites Metadata
- Get Open Learning Items List
- API - Program Enrollment Summary
- API - Course Enrollment Summary
- Get Catalog Items List
- API - Course Session Members list
- API - Program Members List
- Event participants list
- Api - Test Attempts (Test Instances) List
- Test instance details list
- Api - Non Subscribed Event List
- Api - Subscribed Event List
- API - List All Report Schedules
- API - Get Latest Report Content For A Given Schedule ID
- API - Get Report Content For A Given Report ID
- API - List Reports For A Given Schedule
User Management
- API - User list
- API - Get user details
- Api - User Creation
- API - Create User (With Custom Properties)
- API - Update User
- API - Rename User
- API - Add user to group(s)
- API - Remove user from group(s)
- Merge User Accounts
- API - Activate User
- API - Deactivate User
- API - Change User's Origin Site
- Api - User Login (Creating User Session)
eCommerce
API Documentation
Examples
- User Creation
- User Update
- User List
- Get User Details
- Add User to Group(s)
- Remove User from Group(s)
- User Activate
- User Deactivate
- User Login
- Group List
- Group Membership
- Course Subscription(Coupon Code)
- Subscribed Events List
- Non Subscribed Events List
- Test Instances in Microsite
- Forum APIs
- Javascript Example
Client Example
Quick Links
- Home
- Getting Started
- Knowledgebase
- Video Tutorials
- Google Apps Integration
- Gilly (Plugin for Atlassian Confluence)
Comment