Trying to implement Outlook Calendar API

Hi,

I'm trying to create an application for my company where the users can view their Calender and see how many days they have had off/how much holiday they have left etc. It is used by all employees of the company and they want to be able to view one Outlook calendar that will show all who has had days off/will have days off etc.

I'm trying to do this through consuming the REST API Method of the Calender using this guide:

https://docs.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/calendar-rest-operations#GetEvent

However I've spent quite a long time trying to figure out how to consume the method URL...an example URL I have tried is:

"https://outlook.office.com/api/v2.0/me/calendar" (I have also tried replacing 'me' with my company email address) but I keep getting the response "HTTP/1.1 401 Unauthorized"

I'm not sure I'm going about this the correct way (or even if what I want to accomplish is possible) so was wondering if anyone could point me in the right direction...not to completely answer the question but just so I don't waste many hours looking down paths that lead nowhere.

I've also looked at potentially using some Forge extensions such as "https://www.outsystems.com/forge/component-overview/1579/exchange-web-services"

And also wasn't sure whether I needed to register to "https://docs.microsoft.com/en-us/graph/auth-register-app-v2" in order to enable me to use the Outlook REST API's?

Any replies would be greatly appreciated,

Aaron

Hi Aaron,

Yes, I would say that you need to register your app and authenticate before calling the other methods.

As mentioned here.

From the quick overview, I've made when registering you will also need to provide the scope (permissions) your app will need, that will also influence which methods will be available for you to call.


Hope this help.

In addition to the previous post try to search in the Forge for 365, you will see some connectors for Microsoft it's possible that some of the API's are already there and also gives you a better context of what you need to do in order to use them.

Ok, I'll see if I can do that. Thank you!

@Aaron: After try Nuno suggestion, please give feedback.... I am also interested on the subject.


@ Nuno: By the way can we do it with  exchange server?


Regards

I really don't know where to start with this. I have logged into azure through my work email and have tried to register a new application, however when I tried to enter the login page of my (not nearly completed) app it said it "Must start with "HTTPS" or "https://localhost", and it is just the development IP address (Not licenced for production).

I'm so stuck, I have tried using Microsoft Graph, and  if I sign in with my company email, I can receive a response from the request "https://graph.microsoft.com/v1.0/me/messages" but when I try anything to do with Outlook, such as this "https://outlook.office.com/api/v2.0/me/calendarview?startDateTime=2014-10-01T01:00:00&endDateTime=2014-10-31T23:00:00&$select=Subject" then nothing happens. I must have spent a good 10 hours reading and trying and making no progress here.

I'll try to see if I can get the users signed in and authenticated first, I think I was doing that in a way that was far too basic.

Hi Aaron,

From the information you provided, I think you need to have a certificate in your DEV environment, in order for you to provide an HTTPS connection. 

Hey,

Thanks for your responses for far. I've managed to get a lot further with the information you provided - I did indeed need a certification for the DEV environment to access HTTPS connection.

I've managed register my App in Azure, added the API permissions to be able to sign in and used the Microsoft Login Connector and so now I can login using Office365 company credentials. I have also set up a Wrapper Token server action to use through Microsoft Login Connector that gets me a token I need to access the Office365 API's that I need. I've put it in the preparation of a screen and it seems to work as intended. However, when trying to consume a REST API in outsystems (I ass single method, and use GET "https://outlook.office.com/api/v2.0/me/calendar" as the Method URL) I get the Response 'HTTP/1.1 401 Unauthorized'.

When I enter "https://graph.microsoft.com/email", I get the Response:

"HTTP/1.1 401 UnauthorizedContent-Type: application/json; charset=utf-8(Show all headers){  "error": {    "code": "InvalidAuthenticationToken",    "message": "Access token is empty.","

 So I assume I have to get and put my token value somewhere in Headers / Auth...but I'm not sure where, and how to get the token while I'm setting up the REST API?

Sorry to keep asking, but quite stuck again now. 

Thanks in advance,

Aaron

Edit: I have got closer to the solution, I think. I put an 'Authorization' request header in, and used the GetUserToken.token that had the generated token in the REST method. When I tested, I got the response:

'HTTP/1.1 401 Unauthorized

Content-Type: application/json; charset=utf-8

{

  "error": {

    "code": "InvalidAuthenticationToken",

    "message": "Access token validation failure. Invalid audience."


So I think it read the token, but didn't validate it for some reason? I used the same username and password as I had logged in with via Microsoft Login Connector in the 'Basic Authentication values'