I am writing a client side JS app and I am having some trouble with the REST interface to Domino server (version 8.5.3 with OSGi extension), the GET part works but I am having issues with the POST see code below. This creates a document in Domino/Notes when I click on it I get the follow messages
Note Item not found
tmpStartTime_Local : incorrect data type for operator or @Function Time/Date expected
I then tried to fill in all the “tmp” time fields this can create a document but it is not correct either. I also tried to use the “Notice” rather than appointment form again no good.
When I open the document in Notes it say it is an Agenda Item but not a meeting and also that it is recurring which it is not. It appears in “all documents” but not in the Calendar or the resource reservation. I think it is either I am not setting the correct values for an appointment document or I am not calling the correct service any ideas how to correct ?
function postREST()
{
var msg=
{
"Subject":"TEST C3",
"Body":"The date/time variant is basically just a floating-point number with the date as the integer part and the time as the fractional part. It can be freely converted back and forth to a Double, without losing information.",
"$PublicAccess":"1",
"$BusyName":"CN=Administrator/O=acme",
"$BusyPriority":"1",
"$ApprovalList":"CN=Administrator/O=acme",
"$CSFlags":"uw",
"$CSCopyItems":["Room"],
"$Programmatically": "1",
"ExcludeFromView": ["D","S" ],
"MailOptions":"0",
"AllowBusyAccess":"",
"NoticeType" : "I",
"AutoProcessType":"0",
"AutoProcessUserList":"Administrator",
"Room":"Room2\/ZAC Atalante champeaux@acme",
"AppointmentType":"3", // 0 = Appointment 3 Meeting
"Form":"Appointment",
"_ViewIcon":158, // Meeting
"Repeats":"", // doesn't appear to do much
"Chair":"CN=Administrator\/O=acme",
"Principal":"CN=Administrator\/O=acme",
"From":"CN=Administrator\/O=acme",
//"From":"CN=Administrator",
"AltChair":"CN=Administrator\/O=acme",
"SequenceNum":1,
"OrgTable":"C0", // Calendar entry 0 => first Calendar
"Logo":"StdNotesLtr25",
"StartTime":"10:00:00",
"StartDate":"2014-02-17",
"EndTime":"11:00:00",
"EndDate":"2014-02-17",
"CalendarDateTime":"2014-02-17T09:00:00Z",
"StartTimeZone":"Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=68$ZN=Romance",
"EndTimeZone":"Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=68$ZN=Romance",
"WhiteBoardContent":
{
"type":"multipart",
"content": [
{
"contentType":"text\/html; charset=US-ASCII",
"contentDisposition":"inline",
"data":"<html><body>HELLO WORLD<\/body><\/html>\r\n\r\n"
}
]
},
}
try {
var Amsg = JSON.stringify(msg);
}
catch (err) {
log(": Exception:"+ err);
}
var url = "http://99.99.99.99/mail/administ.nsf/api/data/documents?form=Appointment";
var username = "admin";
var password = "pwd";
try{
xhr = new XMLHttpRequest();
xhr.addEventListener("loadstart", function(evt) { //log("loadstart");log(evt);
}, false);
xhr.addEventListener("progress", function(evt)
{ //log("progress");log(evt);
}, false);
xhr.addEventListener("error", function(evt) {
error("xmlhttprequest ERROR");
log("ERROR readyState : " + this.readyState + " status : " + this.status + " " + this.statusText);
log("ERROR responseText : " + this.responseText);
log("ERROR responseXML : " + this.responseXML);
error(evt); }, false);
xhr.addEventListener("abort", function(evt) { error("abort"); error(evt); }, false);
xhr.addEventListener("load", function(evt) { //log("load");log(evt);
}, false);
xhr.addEventListener("loadend", function(evt) {
log("loadend ANSWER : readyState : " + this.readyState + " status : " + this.status);
postReturn(this.responseText);
}, false);
xhr.open("POST", url, true, username, password);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(msg);
}
catch(err) {
log(": Exception:"+ err);
}
}
For Domino 8.5.3, the data service is the only REST service available.
It gets better in Domino 9.0. That gives you the option of using the extension library from OpenNTF to install the Domino calendar service. The calendar service is much better suited to your use case. It doesn't require in-depth knowledge of the Notes C&S schema and automatically handles scheduling workflow as you create, update and delete events.
Also, the calendar service is built into Domino 9.0.1. So 9.0.1 doesn't even require a separate extension library install.
However, assuming you are constrained to 8.5.3 and the data service, I have an idea what is causing the "incorrect data type for operator" error. Your JSON input is defining each data/time item as a plain string. You might have better results declaring the data type like this:
So you could try explicitly declaring the data type for each date/time item, but I personally have never tried to create a calendar event with the data service. Even if you get past this error, I wonder if there will be more problems ahead.
You are missing at least two items: StartDateTime (a combination of Startdate and StartTime) and EndDateTime (guess...).
Check out the Calendaring and Scheduling Schema to find out other missing items.
In addition you can check the data types of the items in the document (Alt - Enter on the document in the calendar view), as they might be of type text. Then change your code as suggested by Dave.