-->

How to tell when to use EWS vs rest API in Outlook

2019-05-20 06:06发布

问题:

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.

回答1:

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.