Search code examples
microsoft-teamsmicrosoft-graph-teamsteams-toolkit

Microsoft Teams for Organisations - deleting message in channel using curl


I am trying to delete messages from a channel in Teams using curl.

I can post to a channel using a token and channel-id found when creating a Connector/web hook.

I can do this:

curl -H "Content-Type: application/json" -d '{"text": "Hello from curl!"}' https://<custom org>.webhook.office.com/webhookb2/<token>@<channel-id>/IncomingWebhook/<channel-id>

Now how can I delete a message again, using curl?

Note: I am on Teams for an Organisation


Solution

  • On the Beta you can use softDelete

    Note: Microsoft have chosen not to use the DELETE method, but instead use a POST method

    POST https://graph.microsoft.com/beta/users/8f98f01d-1a73-401a-b9e9-9fd1e6f5e5ar/chats/19:[email protected]/messages/1649864053377/softDelete
    

    Source