I am trying to use the Graph API's Teams Export API to export all messages in a single Teams channel. I know that my permissions are set up correctly - if I request GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages
, I get a list of every message in every channel in the team. The linked documentation also includes a sample request that uses $filter
to get results with a lastModifiedDateTime
between two limits; I get the expected results from calling something like this.
The obvious approach is to request https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=channelIdentity/channelId eq '{CHANNEL_ID}'
. This returns the following error:
{
"error": {
"code": "BadRequest",
"message": "The entity property 'channelIdentity/channelId' and operationKind 'Equal' is not allowed in $filter query.",
"innerError": {
"date": "2022-11-17T18:27:18",
"request-id": "...",
"client-request-id": "..."
}
}
What I'm gathering here is that we can't run an equality operation on this field. Is there some kind of documentation specifying which operations are allowed on which fields?
I also tried using startswith
instead. GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=startswith(channelIdentity/channelId, '{TRUNCATED CHANNEL ID}')
returns this error:
{
"error": {
"code": "BadRequest",
"message": "Only binary operation expressions are allowed.",
"innerError": {
"date": "2022-11-17T18:38:05",
"request-id": "...",
"client-request-id": "..."
}
}
}
I have no idea what this error message is trying to tell me. As I read it, a "binary operation expression" should resolve to a boolean result on each candidate; I don't see why that wouldn't work with this query.
My primary question is, how do I return only results from a single channel from the Teams Export API? Is it even possible to do so using $filter
?
Another strange behavior I noticed: the sample query on the documentation gets the top 50 results between two lastModifiedDateTime
s: GET https://graph.microsoft.com/v1.0/teams/{id}/channels/getAllMessages?$top=50&$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z and lastModifiedDateTime lt 2020-06-05T21:00:09.413Z
. This works as expected. If I remove one of the date limits, though, I get an error: GET https://graph.microsoft.com/v1.0/teams/{id}/channels/getAllMessages?$top=50&$filter=lastModifiedDateTime gt 2020-06-04T18:03:11.591Z
returns "message": "Invalid $filter query."
. What is invalid about this filter?