返回Office 365邮件REST API预览中的所有电子邮件元数据 [英] Return all email metadata in Office 365 Mail REST API preview
问题描述
如何从Office 365 API预览版的一部分的Mail REST API返回所有元数据?
How do I return all the metadata from the Mail REST API that is part of Office 365 APIs Preview?
msdn文档似乎表明您发送的Accept标头的值为" application/json; odata.metadata = full ",但这导致返回的属性数量有限并且不包括电子邮件的正文.
The msdn docs seem to be indicating that you send an Accept header with the value of "application/json;odata.metadata=full", but that results in the limited number of properties being returned and doesn't include the body of the email.
http://msdn. microsoft.com/en-us/library/office/dn605901(v=office.15).aspx
我也尝试过" odata = verbose ",结果相同.这是在两种情况下都会返回的json:
I have also tried "odata=verbose" with the same result. Here is the json that gets returned in either case:
{
"@odata.context":"",
"@odata.id":"",
"@odata.editLink":"",
"Id":"",
"Subject":"",
"DateTimeReceived":"",
"From":{},
"Attachments@odata.navigationLink":""
}
更新:
REST端点: https://outlook.office365.com/ews/odata/Me/Inbox/Messages
罗希特·纳加马尔(Rohit Nagarmal)的回答为我指明了正确的方向.我在$ select查询参数中指定了一个字段列表,该字段覆盖了Accept标头的完整元数据设置.删除$ select查询后,将返回完整的元数据.
Rohit Nagarmal's answer pointed me in the right direction. I had a list of fields specified in the $select query parameter, which was overriding the Accept header's full metadata setting. Once I removed the $select query, full metadata was returned.
推荐答案
可以共享用于访问消息的URL吗? 如果您使用类似: https://outlook.office365.com/ews/odata/Me/Inbox/Messages 您应该在响应中看到Body属性. 您还可以使用$ select专门请求选择属性.例如: https://outlook.office365.com/ews/odata/Me/Inbox/Messages ?$ select = Subject,Body& $ top = 1
Can you share the url you are using to access the Messages? If you are using something like: https://outlook.office365.com/ews/odata/Me/Inbox/Messages you should be seeing the Body property in the response. You can also specifically request selective properties using $select. For example: https://outlook.office365.com/ews/odata/Me/Inbox/Messages?$select=Subject,Body&$top=1
$ top可用于限制返回的项目数.
$top can be used to restrict the number of items returned.
如果指定了$ select,它将覆盖Accept ="odata.metadata = full"设置,并且仅返回$ select查询中指定的字段.
If $select is specified, it will override the Accept="odata.metadata=full" setting and will return just the fields specified in the $select query.
这篇关于返回Office 365邮件REST API预览中的所有电子邮件元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!