问题
Right now I use the ewsURL to fetch the attachments through a SOAP request. My Outlook Addin gets the ewsURL with a token and send it to the server and the server uses that to get the attachments. The problem is, this does not work for the mobile app. In mobile, I can't get the ewsURL. According to the docs, I have to use the REST API but it's not clear how to use it on the server side. Any help?
回答1:
On the add-in side, there are a couple of differences when using Outlook REST APIs from an Outlook add-in:
- Modify the getCallbackTokenAsync API call to include the isRest parameter.
- Use the convertToRestId API on the itemId before sending it to the back-end.
On the server-side, here are some steps on getting started with Outlook REST APIs. The code you use to call the API will be different depending on the server-side language, and there are language-specific steps under the getting started section.
The main difference will be instead of registering the application and implementing OAuth2, you will be able to skip to the step where you use the Mail API (Node.js) and use the REST access token returned by the add-in API.
For calling the attachment API, see the docs for listing attachments on an item and getting attachments.
To test the token returned by the getCallbackTokenAsync API, try making a request like this one:
GET https://outlook.office365.com/api/v2.0/me/messages/<item id>
Authorization: Bearer <REST token>
来源:https://stackoverflow.com/questions/54412828/how-to-use-rest-to-download-outlook-attachments-from-a-node-server