Updates a course using PUT.
If a parameter is left out, the current value in Frontcores database is kept. Fields the endpoint doesn't know are ignored; the response then lists them in ignored_fields, so a request that changed less than you meant shows it. A request that sends only labels, tags, texts or the price works on its own; {"error": "No fields sent"} (400) means none of the fields sent is one the endpoint knows.
For every API request you make, you'll need to present the API access key in the HTTP Header as X-API-Key to be authenticated.
| Name | Required | Value | Description |
|---|---|---|---|
| title | optional | string | Title of the course |
| active | optional | bool | Default is 1 |
| reference | optional | string | Your own reference, if needed. |
| is_full_time | optional | bool | Default is null (not set) |
| is_part_time | optional | bool | Default is null (not set) |
| level | optional | integer | Default is 6 ("Courses")
|
| form_of_teaching | optional | integer | Default is 1 ("Classroom")
|
| teaching_language | optional | string | Default is no ('no' as in Norwegian)
|
| time_of_day | optional | integer | Default is null (not set)
|
| duration_value | optional | integer | Default is null (not set) |
| duration_unit | optional | integer | Default is null (not set)
|
| price_value | optional | integer | Default is null (not set) |
| price_currency | optional | string | Three-letter ISO currency code of price_value, e.g. NOK, EUR or SEK. It is the currency bookings use. A currency id is also accepted. When a course is added without it, the account's main currency is used; when a course is updated without it, the currency is kept. Changing it also changes the currency of the course's member price. The amount is not converted. |
| price_comment | optional | string | |
| publishing_platform | optional | string | Where the course is published: internal (only in your own booking pages), kursguiden, both or hidden. Default on a new course: both. Another value is ignored and listed in ignored_fields. |
| lessons_hours | optional | integer | Training hours: the number of hours the course should have. Shown as "Training hours" on the Advanced tab of the course in FrontCore, and used with attendance. Send an empty value to clear it. lesson_hours is also accepted. |
| tags | optional | array | List of tag identifiers. Accepts either a plain array of IDs or a JSON-encoded array of tag objects. |
| labels | optional | array | List of label identifiers from GET /v2/labels (e.g. [1487]). Accepts either a plain array of IDs or a JSON-encoded array of label objects. It replaces the course's labels. Read them back with include[]=labels on GET /v2/courses or GET /v2/courses/:id. |
| text_lead | optional | string | ~170 characters are visible on Kursguidens listing pages. |
| text_description | optional | string | Can contain HTML |
| text_place | optional | string | Can contain HTML |
| text_prerequisites | optional | string | Can contain HTML |
| text_duration | optional | string | Can contain HTML |
| text_credits | optional | string | Can contain HTML |
| text_submissions | optional | string | Can contain HTML |
| text_hotel_info | optional | string | Can contain HTML |
| text_audience | optional | string | Can contain HTML |
| email_booking | optional | string | E-mail address |
| email_more_info | optional | string | E-mail address |
| external_booking_url | optional | string | Lead form - booking registration. |
| external_more_info_url | optional | string | Lead form - request for more info. |
$post_params = array();
$post_params['title'] = 'Learn REST API';
$post_params['active'] = '1';
$post_params['reference'] = 'RESTAPI-CA-1001';
$post_params['is_full_time'] = '0';
$post_params['is_part_time'] = '1';
$post_params['level'] = '6';
$post_params['form_of_teaching'] = '1';
$post_params['teaching_language'] = 'no';
$post_params['time_of_day'] = '2';
$post_params['duration_value'] = '6';
$post_params['duration_unit'] = '6';
$post_params['price_value'] = '1500';
$post_params['price_currency'] = 'NOK';
$post_params['price_comment'] = 'Includes a free beer.';
$post_params['tags'] = [1,2]; // or [["id" => 1], ["id" => 2]];
$post_params['text_lead'] = 'REST API is very useful.';
$post_params['text_description'] = '<p>REST API is a easy way of sharing information between sites.</p>';
$post_params['text_place'] = '<p>At IT Fornebu.</p>';
$post_params['text_prerequisites'] = '<p>Normal programming skills.</p>';
$post_params['text_duration'] = '<p>2 sessions. Each session is 3 hours.</p>';
$post_params['text_credits'] = '<p>No credts.</p>';
$post_params['text_submissions'] = '<p>Two tasks to be submitted online.</p>';
$post_params['text_hotel_info'] = '<p>Scandic Fornebu.</p>';
$post_params['text_audience'] = '<p>Programmers and web developers.</p>';
$post_params['email_booking'] = 'booking@exampleschool.no';
$post_params['email_more_info'] = 'more.info@exampleschool.no';
$request_url = 'https://api.frontcore.com/v2/courses/22353';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_params));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-API-Key: {your-api-key}',
'Accept: application/json',
));
$result = curl_exec($ch);
curl_close($ch);
If the method is successful it responds with an JSON structure, as it is shown below.
{
"course_id": 22353
}
Unsuccessful response sample:
{
"course_id": 22353
}