2
votes

I'm following the Microsoft Graph tutorial to create and send a chat message to a Microsoft Teams channel from C#.

However, I'm getting an error when following the first example when trying to create a ChatMessage object. (var chatMessage = new ChatMessage...) The error is:

The type or namespace name 'ChatMessage' could not be found (are you missing a using directive or assembly reference?)

I've added the following references to my project already but none of them seem to contain the ChatMessage class definition:

  • Microsoft.Graph
  • Microsoft.Graph.Core
  • Microsoft.Graph.Auth

The ChatMessage documentation gives me a little more information on the ChatMessage resource type but doesn't tell me where I should get it from.

The only other thing I've found is Windows.ApplicationModel.Chat.ChatMessage, but I can't find windows.applicationmodel.chat in Nuget, and I'm not sure if this is actually correct as there's no mention of it on the Graph tutorial page.

What am I doing wrong to be able to use the ChatMessage object in the tutorial?

1
Windows.ApplicationModel.Chat is only available in UWP as far as I'm aware. - Adam McMahon
Have you added a reference to Microsoft.Graph.Beta? - Adam McMahon
I have run in to the same problem as you, so now I know I need to use the beta version of the package - but just wanted to ask you did you get this to work as in send a message to a channel? - Ayo Adesina

1 Answers

4
votes

In order to call into the Beta version of Microsoft Graph (i.e. /beta/...), you need to use the Microsoft.Graph.Beta NuGet package, not the Microsoft.Graph package. The later only contains APIs that have been released (i.e. /v1.0/...).