I am trying to send message to teams Channel but i am getting below error -
Can anyone please help ?
RESPONSE -
{
"error": {
"code": "Unauthorized",
"message": "Message POST is allowed in application-only context only for import purposes. Refer to https://docs.microsoft.com/microsoftteams/platform/graph-api/import-messages/import-external-messages-to-teams for more details.",
"innerError": {
"date": "2023-05-30T04:07:23",
"request-id": "14e70f9f-46f4-45dc-99ab-2bb0094ded3f",
"client-request-id": "14e70f9f-46f4-45dc-99ab-2bb0094ded3f"
}
}
}
ACCESS TOKEN -
curl --location 'https://login.microsoftonline.com/64c0b******c-99c6-e***ac44/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=8c4d5231-e***********3f8e1d9c' \
--data-urlencode 'scope=https://graph.microsoft.com/.default' \
--data-urlencode 'client_secret=VfS8************n2PLhcqjcRC' \
--data-urlencode 'grant_type=client_credentials'
cURL for Sending Message to Teams Channel -
curl --location 'https://graph.microsoft.com/v1.0/teams/0c1a5839**********-abdd-bb5772cf50ee/channels/1**********c7872b9bb@thread.tacv2/messages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer accessToken