This morning I saw a question on StackOverflow that I had a look at. Basically, the person asking had tried to update an existing calendar entry - without success. As I have been playing a little with REST I thought I would give it a quick go. And correct, it couldn't be done the way the person asking the question had tried.
So let's get some basics in place:
Being armed with this knowledge I started out trying with a PATCH approach... Long story short - the calendar service seem not to allow PATCH requests. So that one is out of the question. And having said that I have not found any places in the documentation stating that it would support PATCH methods. So all fine...
I then tried a PUT request and with a little playing around (and with the help of the documentation for Domino Access Services (DAS) 9.0.1) I made it work :-)
First I specified the request with ALL fields from the result of either querying the event (or when creating it). Following subsequent tests I found that this is not necessary - but you have be aware of the defaults being added for the fields you do not specify - e.g. if you only specify a start time (as in the StackOwerflow question) you get the same end time... So you may want to specify all fields...
Example of a request:
{
"events": [
{
"href": "\\/demo\\/cal.nsf\\/api\\/calendar\\/events\\/0C3AC054CE152609C1257E9D00204F95-Lotus_Auto_Generated",
"id": "0C3AC054CE152609C1257E9D00204F95-Lotus_Auto_Generated",
"summary": "Rotary",
"location": "Main room",
"start": {
"date": "2015-03-30",
"time": "18:30:00",
"utc": true
},
"end": {
"date": "2015-03-30",
"time": "20:00:00",
"utc": true
},
"class": "public",
"transparency": "opaque",
"sequence": 0,
"last-modified": "20150810T055255Z",
"x-lotus-notesversion": {
"data": "2"
},
"x-lotus-appttype": {
"data": "0"
}
}
]
}
And then the important thing. In the PUT request you have to specify the FULL id (not just the UNID part) like:
http://json.dalsgaard-data.dk/demo/cal.nsf/api/calendar/events/0C3AC054CE152609C1257E9D00204F95-Lotus_Auto_Generated
And then it works!
I
f you want to know more about what you can do with REST services then check out my presentation from SUTO Lon Slideshare