Updating Microsoft Teams Chats and Managing Attachments via Microsoft Graph API in C# .NET6

Amit 731 Reputation points


I want to update Microsoft Teams Chats (one-on-one / Channel) programmatically via C# .NET6. Additionally, I want to download and delete attachments.

I see that the Microsoft Graph API has an "Update chatMessage" section, but it is not working for me.


Can someone please confirm if we can update/delete chat messages and delete and download attachments via the Graph API?

If yes, could you provide any sample code?

Thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,381 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,053 questions
{count} votes

Accepted answer
  1. Prasad-MSFT 6,096 Reputation points Microsoft Vendor

    Yes, you can update and delete chat messages as well as delete and download attachments via the Microsoft Graph API.

    Updating a Chat Message: To update a chat message, you can use the PATCH request to the /chats/{chat-id}/messages/{message-id} endpoint.


    Deleting a Chat Message: To delete a chat message, you can send a DELETE request to the /chats/{chat-id}/messages/{message-id} endpoint.


    Downloading an Attachment: To download an attachment, you first need to get the attachment ID using a GET request to the /chats/{chat-id}/messages/{message-id}/attachments endpoint. Then, you can download the attachment using the GET request to the /chats/{chat-id}/messages/{message-id}/attachments/{attachment-id}/$value endpoint.

    Deleting an Attachment: Currently, the Graph API does not support directly deleting an attachment from a chat message. You would need to update the message to remove the attachment reference.


    Prasad Das


    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

0 additional answers

Sort by: Most helpful