Creating and updating a course via webservice

In EthosCE most content is a node. This includes, but is not limited to, site pages, series, sessions and courses.  All web service calls to create these pieces of content go to though the node endpoint. Additionally, all fields, including custom fields, can be sent via web service, in creation and update calls. The following structure applies to any course type in the system, with the appropriate changes to field names.

The course type may be updated by changing the type value of the data array sent.

 

Internal Value

 

Internal Value

Course

course

Session

group_event_series_event

Most content types in Ethos use the body field for the main content, except Courses, which use the field_course_summary field, referenced below.

NOTE: When creating or updating an entity

For any call, you must specify the format being posted in a Content-Type HTTP header as "application/json”

Creating a course

The JSON payload below creates a course with the following details:

A live event, on Aug 20 2018, from 9am to 5pm EST, open from Aug 20 2017 to Aug 20 2018.
It includes information on the venue, it's location, website, phone number, and travel information.
The SKU number is DLC_1234, and the price is $100.

After creating the course the internal node id (nid) is returned in the success response.

POST to node.json

{ "title": "My Course", "type": "course", "field_course_summary": { "value": "A <b>summary</b> of the course", "format": "full_html" }, "author": 1, "status": 1, "field_course_date": { "value": "2017-08-20T13:00:00", "value2": "2018-08-20T21:00:00" }, "field_course_event_date": { "value": "2018-08-20T13:00:00", "value2": "2018-08-20T21:00:00" }, "sell_price": 100, "model": "DLC_1234", "field_learning_objectives": { "value": "<p>Objectives for learning.</p>", "format": "full_html" }, "field_hotel_travel": { "value": "<p>Attendees will have a block of rooms available at <b>The Double Tree</b></p>", "format": "full_html" }, "field_hotel_information": { "value": "<p>Please call the front desk for rates.</p>", "format": "full_html" }, "field_hotel_link": { "title": "Venue Website", "url": "doubletree3.hilton.com" }, "field_venue_phone": { "number": "2158931600", "country_code": "us" }, "field_course_location": { "name": "Double Tree Philadelphia", "street": "237 S Broad Street", "additional": "", "city": "Philadelphia", "province": "PA", "postal_code": "19107", "country": "us" }, "field_course_live": 1, // Category and format use Term IDs to assign values "field_course_category": [ { "id": 50 }, { "id": 60 }], "field_course_format": [ { "id": 10 }, { "id": 20 }] }

Attaching credit

Adding credit requires a separate call for each credit type.

You can add 1 hour of non variable Attendance credit and AMA PRA Category 1(tm) credit, claimed at .25 increments up to 5.5 maximum, with the following payloads.

POST to course_credit.json

{ "nid": 123, "active": 1, "type": "attendance", "increments": 0, "min": 0, "max": 1, "enable_variable_credit": 0 }
{ "nid": 123, "active": 1, "type": "ama", "increments": 0.25, "min": 1, "max": 5.5, "enable_variable_credit": 1 }

Updating course fields

When updating any content, the payload sent is trimmed down to only the fields being updated. To update the title of the course created in the previous section, we use the path, http://your-domain.com/node/123.

Note the usage of "PUT" instead of "POST"

PUT to node/123

Updating a course's external ID

After creating a course via web service, clients may need to update the External course ID field, with a value associated to the external system. This update call is different than the title, detailed above.  The title field is attached to the node entity, however the External course ID field is attached to the course entity, a separate collection of data. It is used for primarily for internal purposes, and is seldom changed manually. However, in this case of a course created externally via web service, there may be a need to associate the new course with an external system ID. 

To update the course created in the previous section, we take the nid returned, above example is 123, and send a PUT call, via the course endpoint, to updated the External course ID fieldThe internal name of the field is external_id.

Warning

It is not recommended to update any other fields found in the course endpoint, except external_id, as they are internally created/updated when editing a course via the UI.

PUT to course/NID.json