Monthly Archives: August 2015

Can you update a calendar entry using the DAS REST service?

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:

  • If you want to CREATE data you use a POST request.
  • If you want to change INDIVIDUAL fields then you use a PATCH request
  • If you want to update ALL fields in an extisting record/data set then you use a PUT request.

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!

If you want to know more about what you can do with REST services then come to ICON UK where I will give a presentation on REST Services.

I am going to ICON UK (London) to speak

I have just been accepted to speak at ICON UK 21-22 September in London in England. I am going to speak about REST services in IBM Domino/XWork. This is not at all the first time I am going to ICON UK (formerly UKLUG/ILUG). Actually, I have been at this event several times as it is one of… Læs mere