如何从 Office 365 REST API 检索 ItemAttachment 内容? [英] How to retrieve ItemAttachment contents from Office 365 REST API?

查看:38
本文介绍了如何从 Office 365 REST API 检索 ItemAttachment 内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:非常感谢 Venkat 在下面回答这个问题!

UPDATE: Many thanks to Venkat for answering this below!

为了检索 .msg 附件的内容,get 请求需要格式化如下:

The get request needs to be formatted as follows in order to retrieve the contents of a .msg attachment:

https://outlook.office365.com/api/v1.0/me/messages/{messageid}/attachments/{AttachmentId}?$expand=Microsoft.OutlookServices.ItemAttachment/Item

(原问题)

我最初是在 Microsoft 的 Office 开发人员中心提出这个问题的.其中一位版主要求我在这里提出这个问题.

I originally asked this question in Microsoft's Office Dev Center. One of the moderators requested that I pose this question here.

我在使用 Office 365 邮件 REST API 方面取得了很多成功.但是,当尝试检索附加到其他电子邮件的电子邮件消息(即 .msg 文件等项目附件)时,REST API 无法提供.

I've been having a lot of success using the Office 365 Mail REST API. However, when trying to retrieve email messages that are attached to other emails (i.e., Item Attachments like .msg files), the REST API does not deliver.

当我对附加了 .msg 文件的电子邮件发出这样的 GET 请求时,我获得了所有附件属性除了Item"属性,它应该包含附件(根据此处的 Office 365 邮件 REST API 资源指南:https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesItemAttachment)

When I make a GET request like this for an email that has a .msg file attached to it, I get all the attachment properties except the "Item" property, which should contain the attachment (according to the Office 365 Mail REST API resource guide here: https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesItemAttachment)

获取:https://outlook.office365.com/api/v1.0/me/messages/{messageid}/attachments

GET: https://outlook.office365.com/api/v1.0/me/messages/{messageid}/attachments

回复:

{
  "@odata.context": "https://outlook.office365.com/api/v1.0/$metadata#Me/{messageid}/Attachments",
  "value": [
    {
      "@odata.type": "#Microsoft.OutlookServices.ItemAttachment",
      "@odata.id": "https://outlook.office365.com/api/v1.0/Users('{useremailaddress}')/{messageid}/Attachments('{messageid}')",
      "Id": "{messageid}",
      "Name": "{subject}",
      "ContentType": "message/rfc822",
      "Size": 54425,
      "IsInline": false,
      "DateTimeLastModified": "{timestamp}"
    }
  ]
}

我做错了什么吗?

推荐答案

是的,我们的文档需要更清楚地说明如何检索项目.请尝试 https://outlook.office365.com/api/v1.0/me/messages/{messageid}/attachments/{AttachmentId}?$expand=Microsoft.OutlookServices.ItemAttachment/Item 和让我知道这是否适合您.

Yes, our documentation needs to be much clearer on how to retrieve the Item. Please try https://outlook.office365.com/api/v1.0/me/messages/{messageid}/attachments/{AttachmentId}?$expand=Microsoft.OutlookServices.ItemAttachment/Item and let me know if this works for you.

这篇关于如何从 Office 365 REST API 检索 ItemAttachment 内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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