Microsoft Teams
A Microsoft customizable chat-based workspace.
10,894 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Below is the code which I am using for Updating or editing the text of the teams chat meeting but I am not able to Edit the text. Is there any other way to Update it? If yes then can you please share an example for the same.
Private Async Sub FetchMessage(sender As Object, e As EventArgs)
Try
Dim chatId As String = "" 'Chat ID
Dim messageId As String = "" 'Message ID
Dim accessToken As String = "" 'Access Token
Using client As HttpClient = New HttpClient()
client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Bearer", accessToken)
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
Dim endpoint As String = $"https://graph.microsoft.com/v1.0/chats/{chatId}/messages/{messageId}"
Dim response As HttpResponseMessage = Await client.GetAsync(endpoint)
If response.IsSuccessStatusCode Then
Dim json As String = Await response.Content.ReadAsStringAsync()
Dim message = Newtonsoft.Json.JsonConvert.DeserializeObject(Of ObjResponse)(json)
message.body.content = "Updated message content"
'.Content = New StringContent(message.ToString(), System.Text.Encoding.UTF8, "application/json")
Dim request As HttpRequestMessage = New HttpRequestMessage(New HttpMethod("PATCH"), endpoint) With {
.Content = New StringContent(message.ToString(), System.Text.Encoding.Default, "application/json")
}
response = Await client.SendAsync(request)
If response.IsSuccessStatusCode Then
Console.WriteLine("Chat message updated successfully.")
Else
Console.WriteLine($"Failed to update chat message. StatusCode: {response.StatusCode}")
End If
Else
Console.WriteLine($"Failed to retrieve chat message. StatusCode: {response.StatusCode}")
End If
End Using
Catch ex As Exception
End Try
End Sub
Public Class ObjResponse
Public id As String
Public messageType As String
Public subject As String
Public chatId As String
Public from
Public body
End Class