Monday, 20 November 2017

Working with Calendar events from Office 365

Views
In this article post, let us look at the way of accessing the Office 365 calendar events programmatically using REST APIs.

In the samples shown, calendar events will be accessed from SharePoint portal pages using two ways. One way is to use the graph API and the other way is using the outlook API.


Outlook API vs Microsoft Graph API:


Outlook API has lot of API end points to access the mailbox data in office 365 or other Microsoft mailbox services. It has around 11 API subsets for accessing various components under outlook like calendar, contacts, etc.

Microsoft Graph API, helps getting connected to multiple Microsoft products or services. The services include outlook, teams, SharePoint, people etc. This also helps in accessing other user information as well.

Tuesday, 14 November 2017

Using Webhooks for Posting SharePoint Items into MS Teams with Flows

Views
In my previous post, you would have seen posting the items into Microsoft Teams Channels as conversations using Microsoft Flows. The respective channels will be chosen by selecting the Teams service in the flow configurations.

In this post, let us try to achieve similar kind of functionality, but with a little different approach. As we are all aware that Microsoft Teams will support incoming webhook requests, let us try configuring the webhook URLs.


Webhook:


What is webhook? The external system which posts messages whenever data is available using the endpoint APIs.


How the webhook will help in Microsoft Teams? Take for an example, you are using Teams as a collaboration platform. You need to post data from multiple systems to the team channels for better collaboration. The webhook URL can be generated for a channel and can be shared with other external systems. Whenever the external system has the data for posting, the data will be sent to the teams using the API generated.


Saturday, 4 November 2017

Working with Microsoft Teams from SharePoint Using Graph API

Views
Let us see how to work with Microsoft teams from SharePoint programmatically using Graph APIs.

Microsoft has provided the Graph APIs to work with Microsoft Teams and its channels. Though, it is in a beta version. The graph APIs can be triggered from any of the portals. Here, let us only look at triggering the graph APIs from the SharePoint portals.

For example, the following graph API is used to get all the teams which you are part of.
  • https://graph.microsoft.com/beta/me/joinedTeams


Application with Microsoft Teams Permissions 


First, you need to register the application in Microsoft dev portal, where you need to provide the necessary permissions for accessing the Microsoft Teams data from any portal.
  • Login to the Microsoft applications portal https://apps.dev.microsoft.com
  • Provide the name
  • Copy the Application ID generated. (It will be used as client ID in the SharePoint code in the below section)
  • Add the platform as web and then provide the redirect URL. In our sample, you need to provide the SharePoint page URL you will be using to test the functionality.
  • In the Microsoft Graph Permissions, add User.ReadWrite.All and Group.ReadWrite.All permissions to the both the permissions (delegated and applications permissions).
  • Then save and close the application.


Navigate to the SharePoint page, where you want to test the functionality. Add a content editor web part with jquery script reference.


Acquire Access Token​​ and Hit Microsoft Teams Graph API


Access Token to be acquired for getting the Microsoft Teams data. The request token will be generated by redirect URL. The redirect URL to be built with the help of authentication server URL, domain details, response type, client ID (generated above), resource URL (Graph API URL) and redirect URI (SharePoint Page where the functionality is tested). In the following script file, required logic to get the access token is written.

Once the page is redirected, the access token will be available in the redirected URL. We need to extract the token and the ajax call is made to the graph API using the access token.

Create a custom JavaScript file (teams.js) with the script content available in the below section.



Test


Test the functionality by hitting the SharePoint page URL. The snapshot shows the Microsoft Teams.