 Hello, I'm Jason Johnston, a senior content developer with the Outlook Ecosystems team. Today, I'm going to show you how to connect your Node.js app to Office 365 and get, update, and delete calendar data on your calendar. So let's get started. To start with, I've got this basic Node.js app that we've developed over the previous two sessions. Right now, we can log in and we can do basic calendar sync. And now we'll take those calendar items that we're syncing and be able to take some actions on those. In case you missed the previous two sessions, the code that I'm starting with right now is available in the session two branch in the GitHub repo, which is included in the comments below. Okay, so this app uses the Node Outlook library to do all of the API calls back to the Outlook APIs. We've already got it installed from our previous session. So let's start by taking a look at the app as it stands right now. If I log in and sync my calendar, I get these items in a table with a view item link. Or right now, the view item link doesn't work. So let's fix that. We switch over to our code and in the app.js, we'll add a view item route. This view item route gets the item ID from the query parameters. And then we set up a call to the get event method in the calendar namespace and Node Outlook library. Like with our sync calls, we don't have to use the raw make API call here. Node Outlook already implements this functionality for us. So all we need to do is set this get event parameters object with our access token and the item ID of the event that we want to retrieve. And then call get event. We pass the event that gets returned to us in our callback to the item detail page template. So let's see that in action. Now if we click view item, we actually get some details about the item. And below, we see the raw JSON dump of all the details that come back. Now this is nice, but if you look at our form, we're only displaying a few of the fields here, subject location, how many minutes beforehand the reminder will fire and the start and end time. But if we look at the JSON, we're getting back a lot more data than we're actually using. This may not be that big of a deal, but it is a little wasteful. So we can trim that down and only get back the fields that we care about. To do that, we'll modify our view item route here to add a select. This is a standard OData query parameter, which allows you to specify the fields that you want back on a particular entity. We just separate them with commas and I've included all the ones that we care about and display in the form. And now we just need to add those parameters to our get event parameters so that they're passed to the API call. And that should do it. So if we restart the app now, we should see a smaller result set returned. Again, we see all the fields that we care about being displayed in our form. But this time, the JSON that comes back is much smaller and only includes the fields that we asked for. Since we're looking at the JSON here, take a second to point out some of the new features from the V2 endpoint. One is the time zone. By setting our preferred time zone in the node outlook library, we pass a prefer header which specifies that time zone. So as you can see, our start and end times are returned to us in Eastern Standard Time, which is the time zone that I specified. If we don't set that time zone, these times would come back in UTC time or Zulu time. The other new feature that I point out quickly is the reminders. We have two new properties now in the V2 endpoint on events. Is reminder on and reminder minutes before start. The is reminder on is a Boolean that just tells us if there is a reminder set on the event. And if it is set, reminder minutes before start tells us how many minutes before the start of the appointment, the reminder should fire. Pretty straightforward. Okay, so let's get back to the code. As you can see, we have a couple of new buttons here on the form. Update item and delete item. So let's start by implementing the update item. Okay, so this should look fairly similar to some of the other routes that we've already added. We get the item ID from the query parameters and the access token from our session. We also get the new subject and new location from our query parameters, which are passed in the form when we submit it. Then we construct an update payload. Now notice here that we're only setting subject and location. We're not creating an entire new event entity. Whenever you do an update, you only have to include the fields that you want to change. We package this all up again into a parameters object with the token, the item ID, and our update payload. And we pass that to the update event in the calendar namespace. If it succeeds, we redirect back to the view item view so that we can see our new changes. So let's give it a try. We'll change the subject and the location field and go ahead and update the item. Okay, so as we see here, we're getting an error access denied message. That's because the permissions that we requested in our app only gave us the ability to read the user's calendar. We never requested the ability to write to the user's calendar. So we can change that now. We don't need to modify our application registration. We just need to modify our code to request that scope as part of the login process. So if we go to authhelper.js, we'll swap out the calendars.read scope for the calendars.readwrite scope, and that's all that we need to do. Now, if we restart the app and sign in, we're presented with a consent screen again. That's because we've changed the permissions from the last time that the user granted consent. As you can see, we now have the read and write your calendar's permission instead of just read your calendar. Now we should have the proper permissions to update the item. And now we have the new values in our results. And if we look here, we have the new subject and the new location. And quickly we can verify that it has been updated. Okay, great. So now let's look at updating delete item. Again, node outlook has a built-in function for us here, so we don't have to implement it ourselves. And we get the item ID from the query parameters on the incoming request. And we set up an event parameters, delete event parameters object here with the token and the item ID. And we call delete event. Now here on success, we redirect back to the sync page. And that's because since we deleted the item, we can't view it anymore. If we try to view an item with that item ID, we would get nothing back. Okay, so let's give that a shot and see how that works. Okay, so now that we have delete in place, we'll go ahead and give that a try and see what happens. Let's delete our doctor's appointment because we just don't feel like going to the doctor today. That processes and then kicks us back to the sync calendar page. And that's it, we've added get, update and delete functionality for the calendar to our app. Be sure to check out dev.outlook.com and dev.office.com for more information and getting started materials for node and other platforms with Office 365. If you'd like to get the completed source of the app that we developed over these sessions, you can get that at GitHub. The link will be below in the description. The master branch should reflect the finished app. Thanks for watching.