Update a school

Updates a school in Kursguidens database using PUT.

Request

PUT https://www.kursguiden.no/api/v1/schools

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
title required string Title of the course
active optional bool Default is 1
org_nr required string Organization number
reference optional string Your own reference, if needed.
phone required string Phone
email_admin required string Login e-mail address
email optional string Schools e-mail address
email_booking optional string Default e-mail address for bookings
email_more_info optional string Default e-mail address for more info requests
post_address required string Post address
post_zip required string Post zp number
post_city required string Post city
visit_address optional string Visit address
visit_zip optional string Visit zip number
visit_city optional string Visit city
web_address optional string Website address
text_tagline optional string ~120 characters. Visible on school profile at Kursguiden
text_description optional string Complete school description. Can contain HTML

Example code in PHP

$post_params = array();
$post_params['title'] = 'REST API Example School';
$post_params['active'] = '1';
$post_params['reference'] = 'FOR-NE-1001';
$post_params['org_nr'] = '882 287 093';
$post_params['phone'] = '+47 76 22 99 33';
$post_params['post_address'] = 'Fornebuveien 42';
$post_params['post_zip'] = '1122';
$post_params['post_city'] = 'Bærum';
$post_params['text_lead'] = 'REST API is very useful.';
$post_params['web_address'] = 'http://www.spinnerlabs.no/';
$post_params['text_tagline'] = '<p>Simply the best.</p>';
$post_params['text_description'] = '<p>One of the top schools in the world. Learn about REST APIs.</p>';
$post_params['email_admin'] = 'post@spinnerlabs.no';
$post_params['email_booking'] = 'booking@spinnerlabs.no';
$post_params['email_more_info'] = 'more.info@spinnerlabs.no';

$request_url = 'https://www.kursguiden.no/api/v1/schools';
$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.

{
    "status": "success",
    "school_id": "2904"
}

Unsuccessful response sample:

{
    "status": "failure",
    "message": "Wrong API Key"
}      
© 2024 FrontCore