I need to automate sending messages in some teams channels. I use the POST method on endpoint “https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages”. My JSON looks like this :
"from": {
"application": {
"@odata.type": "#microsoft.graph.teamworkApplicationIdentity",
"id": appId,
"displayName": appName
}
}
When I run this request in a Python script, I receive a 400 error and the body says “Invalid request – User is missing.”. If I try to add “user” in the “from” dictionnary with a valid user Id, I receive a 400 error with message “Only one of user, application, conversation or tag must be specified in identitySet”.
Thus, my question is how can I send a message using my Azure App in a channel ?
I checked and my app has all the permissions needed.
If the problem come from the token, I get it from the msal library :
app = ConfidentialClientApplication(clientId, authority=f"https://login.microsoftonline.com/{tenantId}", client_credential=clientSecret)
result = app.acquire_token_for_client(scopes=["https://graph.microsoft.com/.default"])
Antoine is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.