Posting channel message to Teams facing 400 Bad Request

Tamas Fazekas 21 Reputation points
2022-01-20T12:48:52.587+00:00

Hi!

When I am trying to POST a message to /teams/{team-id}/channels/{channel-id}/messages I am facing a 400 Bad Request. During implementation I was following the steps described in Send chatMessage in a channel or a chat The message is posted to Teams however the response is 400 with no specific error message. I've tried in several environments and only this is not working. I don't have any clue how should I solve the issue.
Please check my request below.

   {  
       "error": {  
           "code": "BadRequest",  
           "message": "Bad Request",  
           "innerError": {  
               "date": "2022-01-20T11:49:37",  
               "request-id": "63d8b596-b4a4-429f-b377-aa41a90ec682",  
               "client-request-id": "63d8b596-b4a4-429f-b377-aa41a90ec682"  
           }  
       }  
   }  

Thanks in advance!

Microsoft Teams | Development
Microsoft Security | Microsoft Graph
Microsoft Teams | Microsoft Teams for business | Other
{count} votes

Accepted answer
  1. Ramjot Singh 861 Reputation points Microsoft Employee
    2022-01-21T09:46:59.17+00:00

    I checked the issue is the teamId u r using does not have the channel you have specified. Use list channels API to figure out the right channelId


2 additional answers

Sort by: Most helpful
  1. CarlZhao-MSFT 46,376 Reputation points
    2022-01-21T08:37:07.68+00:00

    Hi @Tamas Fazekas

    First you have to make sure you are in the team before you can send messages to the team. You can use the Graph Explorer tool for a quick test.

    167164-image.png

    Also, by the way, sending messages doesn't support application permissions.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Tamas Fazekas 21 Reputation points
    2022-01-21T08:47:15.387+00:00

    @Sayali-MSFT
    @CarlZhao-MSFT
    Thank you for your response.
    The message is posted to Teams, however the request comes back with 400 which should mean that the Team Id and the Channel Id is fine.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.