Update a date

Updates a date for a course (start date, end date, place etc.) using PUT.

Request

PUT https://www.kursguiden.no/api/v2/courses/:id/coursedates/:id

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.

Parameters

Name Required Value Description
start_at required string yyyy-mm-dd
end_at required string yyyy-mm-dd
deadline_at optional string yyyy-mm-dd
visible_when_passed_deadline optional bool Default is 1 (not set)
teaching_language optional string Default is no ("no" as in Norwegian)
place_id optional integer Use integer found in this list. Or use place_by_search.
place_by_search optional string If place_id is not set. Search for place and use result if found.
place_additional_info optional string Additional info about the location.
reference optional string Your own reference, if needed.

Example code in PHP

$post_params = array();
$post_params['start_at'] = '2020-04-02';
$post_params['end_at'] = '2020-04-10';
$post_params['deadline_at'] = '2020-03-29';
$post_params['visible_when_passed_deadline'] = '1';
$post_params['teaching_language'] = 'no';
$post_params['place_id'] = '637';
$post_params['place_by_search'] = 'Oslo'; // An example. place_id takes precedence.
$post_params['place_additional_info'] = 'Vika';
$post_params['reference'] = 'COURSE1300';

$request_url = 'https://www.kursguiden.no/api/v2/courses/22353/coursedates/9304810';
$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);
               

Response

If the method is successful it responds with an JSON structure, as it is shown below.

{
    "coursedate_id": 9304810,
    "course_id": 22353
}

Unsuccessful response sample:

{
    "error": "Field(s) not valid: start_at"
}      
© 2024 FrontCore