2

Is it possible to tell either in the XML file or through OfficeJs if the add-in can use the REST API or if it needs to use the older EWS API?

We have an Outlook add-in that needs to support OWA/O365 and Outlook 2016 with a stand alone exchange server. We are wondering if it is possible through the manifest XML file or through OfficeJs to detect the configuration of users account so we can properly access their content with the correct API. The only alternative I can see is to provide two separate add-ins for this, but I assume MS has a solution to this issue.

gr347wh173n0r7h
  • 349
  • 2
  • 14

1 Answers1

3

There isn't a specific API for detecting the server version. You could determine if REST is supported for a given mailbox by checking the value of Office.context.mailbox.restUrl. If this is an on-prem installation it won't return a value.

UPDATE:

If restUrl is returning a result (i.e. https://exch1.mailhost.com/api) then REST should available and could begin using the Outlook REST APIs.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
  • So far works on an OWA/O365 account in the Outlook 2016 client, still need to test with the stand alone exchange server, but this seems to be the solution I was looking for. – gr347wh173n0r7h Aug 01 '17 at 21:39
  • Update: This does not work, when calling `Office.context.mailbox.restUrl`, on an on prem exchange it returns `https://exch1.mailhost.com/api`. – gr347wh173n0r7h Aug 31 '17 at 17:11
  • Looks like it has had an update pushed down. It may still be possible to past that URL to determine if it is local or not but I need to do some testing against that first. – Marc LaFleur Aug 31 '17 at 17:25
  • So MS does not provide a standard way to determine if a user needs to use the Graph API or EWS through the OfficeJs lib. This has to be a common problem in developing an add-in that will work for both OWA and Exchange user. Originally we were told to use EWS for Exchange and Graph for OWA/O365 users by MS. – gr347wh173n0r7h Aug 31 '17 at 18:15
  • You can use EWS against both Online and On-Prem accounts. If you're forced to use EWS for on-prem, I would use it across both. That said, the best long-term option is Microsoft Graph. Graph has a much richer set of APIs and is where all new engineering work is focused. – Marc LaFleur Aug 31 '17 at 18:23
  • Will EWS become deprecated then and if so what is the timeline like on this? We would really prefer the long term solution since Graph is where MS is focusing on. – gr347wh173n0r7h Aug 31 '17 at 20:34
  • I don't have a time table for when EWS would be deprecated but I expect it will be quite some time. There is still a sizable amount of functionality that needs to get moved over to Graph before it would be possible and likely some time longer before it would be feasible given the number of applications that depend on it). – Marc LaFleur Aug 31 '17 at 22:19
  • I've updated my answer. It is imported to keep in mind that is `restUrl` gives you a result, you should be able to use the REST API. The reason for checking if it was `null` was to determine if you needed to fall back to EWS. – Marc LaFleur Aug 31 '17 at 22:25
  • Perfect thanks for your help and insight Marc, updated as the correct answer. – gr347wh173n0r7h Sep 01 '17 at 16:29