Office365api 使用Outlook REST API获取不带ContentBytes的ContentId(或任何文件附件属性)

Office365api 使用Outlook REST API获取不带ContentBytes的ContentId(或任何文件附件属性),office365api,outlook-restapi,office365-restapi,Office365api,Outlook Restapi,Office365 Restapi,在我使用Outlook REST API的应用程序中,为了支持html电子邮件中的内联图像,我需要检索给定电子邮件的ContentId 注意:在html电子邮件中,内联图像是形式为 我设法在urlhttps://outlook.office.com/api/v2.0/me/messages/{message_id}/附件 问题是返回的json还包含ContentBytes,对于大型附件,它可以是任意大的 我尝试了几种语法,只检索我需要的字段,例如: https://outlook.office.

在我使用Outlook REST API的应用程序中,为了支持html电子邮件中的内联图像,我需要检索给定电子邮件的
ContentId

注意:在html电子邮件中,内联图像是形式为

我设法在url
https://outlook.office.com/api/v2.0/me/messages/{message_id}/附件

问题是返回的json还包含
ContentBytes
,对于大型附件,它可以是任意大的

我尝试了几种语法,只检索我需要的字段,例如:

https://outlook.office.com/api/v2.0/me/messages/{message_id}/附件?$select=id、ContentId
'$select=id&$expand=ContentId'

没有一个成功,导致了一个错误的请求

{"error":{"code":"RequestBroker-ParseUri","message":"Could not find a property named 'ContentId' on type 'Microsoft.OutlookServices.Attachment'."}}
url
'/attachments'
处的预期类型为Microsoft.OutlookServices.Attachment,它是和项目附件的基本类型


我想检索文件附件(
ContentId
)的特定成员,或者丢弃结果中包含的大量
ContentBytes
me/messages/{message\u id}/Attachments
的端点返回附件的集合

ContentId文件附件的属性。您可以使用以下代码获取fileAttachment的contentId

GET: https://outlook.office.com/api/v2.0/me/messages/{messageId}/attachments?$select=Microsoft.OutlookServices.FileAttachment/ContentId
编辑:
备注:如果要检索其他字段,请说
Name
注意
$select=Microsoft.OutlookServices.FileAttachment/ContentId,Name
将起作用,而
$select=Name,Microsoft.OutlookServices.FileAttachment/ContentId
将抛出原始问题中提到的错误
me/消息的端点/{message_id}/attachments
返回附件的集合

ContentIdFileAttachment的属性。您可以使用下面的代码获取FileAttachment的ContentId

GET: https://outlook.office.com/api/v2.0/me/messages/{messageId}/attachments?$select=Microsoft.OutlookServices.FileAttachment/ContentId
编辑:
备注:如果要检索其他字段,请说
Name
注意
$select=Microsoft.OutlookServices.FileAttachment/ContentId,Name
将起作用,而
$select=Name,Microsoft.OutlookServices.FileAttachment/ContentId
将抛出原始问题中提到的错误

谢谢!它起作用了,实际上我已经尝试过了以前有过这样的请求,但是$select中有其他字段,我收到了一个错误。必须首先检索ContentId,我编辑了您的答案,因为它对我来说很重要。谢谢!它可以工作,实际上我以前尝试过这样的请求,但是$select中有其他字段,我收到了一个错误。必须首先检索ContentId,我已经编辑了您的答案回答,因为这对我来说很重要。