Register User Into Course Offering

Last modified on February 12, 2014 at 4:57 pm

Overview

Register a user into an offering by creating a new registration record. This is accomplished by sending a request body containing a JSON-encoded object with two properties: userId and offeringId. On success, the response will include a Location redirect header pointing to the URL of the new registration resource.

Examples

Register user for offering

This example demonstrates registration by sending a POST request containing the properties for a new registration. Note that all other properties of the registration are omitted.

Request
POST /dc/api/v5/registrations HTTP/1.1
Host: api.digitalchalk.com
Content-type: application/json
Accept: application/json

{
	"userId" : "6629aeada89133acedfad6d7d110123d",
	"offeringId": "89cd2eada89133acedfad6d766a2d931"
}

Response
HTTP/1.1 201 Created
Content-type: application/json
Location: /dc/api/v5/registrations/65ade781cc98d136543678191005431a
Content-length: 0

Failure Cases

Below is a list of the most common failure scenarios your code should be prepared to handle. This list is not exhaustive.

Validation error

When an attempt is made to create a new registration, several checks are performed first to ensure the registration is valid. The userId and offeringId fields are first verified to ensure they reference valid resources. Next, the provided offeringId is checked against the list of offerings that are available to the given user. There are several reasons an offering may not be available – the given user may already be registered in the offering; they may have previously completed the offering and it has been configured to disallow retakes; or the offering may not be available for registration at all. In these cases, the server will return an HTTP 400 response along with a JSON-encoded description of the error.

In the following example, registration is attempted into an offering which is not yet open for registration. This demonstrates how the server will indicate the problem with the request for this case.

Request
POST /dc/api/v5/registrations HTTP/1.1
Host: api.digitalchalk.com
Content-type: application/json
Accept: application/json

{
	"userId" : "6629aeada89133acedfad6d7d110123d",
\"offeringId": "89cd2eada89133acedfad6d766a2d931"
}
Response
HTTP/1.1 400 Bad Request
Content-type: application/json
Content-length: 210

{
	"errors" : [ "This offering is not available for registration for the given user" ]
}

Reference