如何使用 REST 从节点服务器下载 Outlook 附件? [英] How to use REST to download Outlook attachments from a node server?

查看:56
本文介绍了如何使用 REST 从节点服务器下载 Outlook 附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我使用 ewsURL 通过 SOAP 请求获取附件.我的 Outlook 插件使用令牌获取 ewsURL 并将其发送到服务器,服务器使用它来获取附件.问题是,这不适用于移动应用程序.在移动设备中,我无法获取 ewsURL.根据文档,我必须使用 REST API,但不清楚如何在服务器端使用它.有什么帮助吗?

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?

推荐答案

插件端使用 Outlook 加载项中的 Outlook REST API:

  1. 修改 getCallbackTokenAsync API 调用以包含 isRest 参数.
  2. 使用 convertToRestId API 在将 itemId 发送到后端之前.
  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.

服务器端,以下是关于 Outlook REST API 入门.用于调用 API 的代码会因服务器端语言而异,并且在入门部分下有特定于语言的步骤.

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.

主要区别在于,您无需注册应用程序和实施 OAuth2,而是可以跳到 使用邮件 API (Node.js) 并使用加载项 API 返回的 REST 访问令牌.

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.

有关调用附件 API,请参阅 列出项目的附件获取附件.

For calling the attachment API, see the docs for listing attachments on an item and getting attachments.

要测试 getCallbackTokenAsync API 返回的令牌,请尝试发出如下请求:

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>

这篇关于如何使用 REST 从节点服务器下载 Outlook 附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆