I am trying post message to Microsoft teams channel using Graph API but bot no luck.
First I got Bearer token by making below call.
curl --location --request POST 'https://login.microsoftonline.com/22109ccf-0021-48af-947a-11111111111/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: x-ms-gateway-slice=estsfd; stsservicecookie=estsfd; fpc=ApGgHx8qh5hBlL_RviIqR3XYPIX9AQAAADMMeNgOAAAA' \
--data-urlencode 'scope=https://graph.microsoft.com/.default' \
--data-urlencode 'client_id={client_id}' \
--data-urlencode 'client_secret={client_secret}' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'code=' \
--data-urlencode 'redirect_uri=https://localhost:8080'
Using bearer token got in previous call to post message to teams channel.
but receiving Unauthorized
error , I have added below permissions
Teamwork.Migrate.All (App)
Content-type: application/json
{
"body": {
"content": "Hello World"
}
}
I tried using explore https://developer.microsoft.com/en-us/graph/graph-explorer but getting MethodNotAllowed
error.
Is it possible to post message to MS teams channel by using Graph API ?In documentation it says we can https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http.