【发布时间】:2015-12-01 20:58:06
【问题描述】:
我需要使用 OutLook 365 API 但使用 Outlookservicesclient 执行 OData 查询 $search = "subject:pizza"(在 Outlook 365 sdk 中找到,这个 nuget https://www.nuget.org/packages/Microsoft.Office365.OutlookServices-V2.0/)
看到这个OutLookAPI OData query Reference
使用 HttpClient 可以正常工作,但使用 .NET 客户端库时,似乎无法添加任何非标准查询参数。
即:var messages = await client.Users['mail@me.com'].Messages
.Where(m => m.IsRead == false)
.Take(50)
.ExecuteAsync();
产生如下RequestURI https://outlook.office365.com/api/v2.0/Users('mail%40me.com')/Messages?$filter=IsRead eq false&$top=50并正确执行。
如果尝试以下操作,var query = client.Users['Mail@me.com'].Messages
.Context.CreateQuery<Message>("Users('Mail@me.com')/Messages")
.AddQueryOption("$search", "subject:pizza");
要么返回Exception:Thrown: "Can't add query option '$search' because it begins with reserved character '$'." (System.NotSupportedException) A System.NotSupportedException was thrown: "Can't add query option '$search' because it begins with reserved character '$'."
如果我省略 AddQueryOption 行,我会遇到身份验证错误。
我需要做的就是追加$search=subject:pizza RequestURI!如果不实际使用 rest 客户端,这似乎是不可能的,因为 Outlook 客户端似乎仅限于内置的 Linq 方法。
添加了客户端库没有参考文档的事实,我遇到了死胡同。有谁知道是否可以通过outlookservicesclient 包含$search?
【问题讨论】:
标签: c# odata office365 office365api office365-restapi