How to use REST to download Outlook attachments from a node server?

隐身守侯 提交于 2021-02-18 18:57:48

问题


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:

  1. Modify the getCallbackTokenAsync API call to include the isRest parameter.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!