Instructie

Beispiele und Erläuterungen zur Verwendung der API

Es ist ratsam, die Anfrage z. B. mit der RESTClient Extension im Mozilla-Webbrowser zu testen.

Die API-Anfrage wird mit einem Content-Type-Header mit dem Wert application/json versehen.

Content-Type: application/json

Wenn bei der Anfrage eine Authentifizierung mitgesendet werden muss, können Sie zwischen Basic und oAuth wählen.

Authorization: Basic GECODEERDEINFOkbdfgdfgWlu

Curl-Beispiel mit Content-Type- und Basic-Login-Headern

curl -X GET -k -H 'Content-Type: application/json' -H 'Authorization: Basic GECODEERDEINFOkbdfgdfgWlu' -i 'https://{domein}.i-reserve.net/api/rest/booking/current/'

Javascript-Beispiel


function fetchFeed() {
 var xhrRq = new XMLHttpRequest();

 xhrRq.open('GET', 'https://domein.i-reserve.net/api/rest/bookingfilter?columns=CUST_COMP_NAME,COMP_NAME,OBJ_DESC,OBJ_LONG_DESC,OBJ_TXT_CUSTOM02,RES_CUSTOM03,RES_CUSTOM04,RES_FROMDATE,RES_FROMTIME,RES_TILTIME&search=startdatum >= "-1d"', true);
 xhrRq.setRequestHeader("Content-type", "application/json");
 xhrRq.setRequestHeader("Authorization", "Basic " + btoa("API_loginnaam:API_wachtwoord"));
 xhrRq.send();
 xhrRq.onload = function () { var response = JSON.parse(xhrRq.response); displayfeed(response) }
 xhrRq.onerror = function (e) { console.log("error event: "); console.log(e);} 
 xhrRq.onabort = function (e) { console.log("abort event: "); } 

 setTimeout(fetchFeed, 900000); //fetch new feed every 15 minutes 
}




var maincontent = document.getElementById("maincontent");

function displayfeed(feeds) {
var d = new Date();
var today = d.getFullYear()+'-'+('0' + (d.getMonth()+1)).slice(-2)+'-'+('0' + d.getDate()).slice(-2) ;
var time_in_sec = Number(d.getHours()*60*60) + Number(d.getMinutes()*60) + Number(d.getSeconds());

addcontent='';
for (var i = 0; i < feeds.length; i++) {
  addcontent += "<div class='meeting";

  if (today == feeds[i].RES_FROMDATE_raw && (feeds[i].RES_FROMTIME_raw<=time_in_sec && feeds[i].RES_TILTIME_raw>=time_in_sec) ){
   addcontent +=" active";
  }
  addcontent += "'><img src=\"https://domein.i-reserve.net/site/assets/files/image.png\"/><h1>" + feeds[i].COMP_NAME + " - " + feeds[i].OBJ_LONG_DESC + "</h1>";
  addcontent += "<b>" + feeds[i].RES_FROMDATE + "<br/>" + feeds[i].RES_FROMTIME + " tot " + feeds[i].RES_TILTIME + " uur</b></div><br/>";

}
 maincontent.innerHTML=addcontent;

}