本文介绍了通过Office365 API提取由sessionIdId过滤的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在弄清楚如何使用office365 api提取给定conversationId的消息时遇到了麻烦.

I'm having some trouble figuring out how to use the office365 api to fetch messages given a conversationId.

比方说我的对话ID是AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=

Let's say my conversationId is AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=

我会发出类似的请求

https://outlook.office.com/api/v1.0/me/Messages?$filter=ConversationId%20eq%20AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=

这将导致如下所示的400响应:

This results in a 400 response like this:

{
  "error": {
    "code": "RequestBroker-ParseUri",
    "message": "Syntax error at position 98 in 'ConversationId eq AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow='."
  }
}

我尝试了其他方法,例如将URL编码的sessionId编码为AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow%3D,这会导致相同的错误.

I tried other things, such as url encoding the conversationId to AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow%3D which results in the same error.

我也尝试过简单地删除=,这似乎是使它崩溃的原因

I also tried simply removing the = which seems to be the character that is freaking it out

https://outlook.office.com/api/v1.0/me/Messages?$filter=ConversationId%20eq%20AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow

但是会导致以下错误

{
  "error": {
    "code": "RequestBroker-ParseUri",
    "message": "Could not find a property named 'AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow' on type 'Microsoft.OutlookServices.Message'."
  }
}

我还尝试过弄乱URL的大写字母,并使用+符号而不是%20作为过滤字符串,但是我始终收到400个错误.

I've also tried messing with the url capitalization and using + signs instead of %20 for the filter string, but I consistently get 400 errors back.

我仍然可以按其他字段进行过滤.例如

I am able to filter by other fields though. For example

https://outlook.office.com/api/v1.0/me/Messages?$filter=IsRead%20eq%20true

返回经过过滤的邮件.

您知道ConversationId过滤器会发生什么情况吗?

Any idea what could be going on with the ConversationId filter?

推荐答案

您需要用单引号将ConversationId换行.这就是我在C#中伪造请求的方式

You need to wrap the ConversationId with single quotes.This is how I forge my request in C#

string finalUrl = "https://outlook.office.com/api/beta/me/Messages?$filter=" + HttpUtility.UrlEncode(string.Format("ConversationId eq '{0}'", conversationId));

这篇关于通过Office365 API提取由sessionIdId过滤的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 22:31