Teams Incoming Webhook response Bad payload received by generic incoming webhook

양정우 [pororoca] 20 Reputation points
2023-07-13T02:59:08.5+00:00

Hello,

Recently, I found about Teams Incoming Webhook response is error, and the content is as in the title, wrote above.

We have been sending request via .net httpclient, to Teams Incoming Webhook connector.

And we did set request header as below.

ContentType = application/x-www-form-urlencoded

I did read documentation about Teams Incoming Webhook at recent, and I found out Content-Type have to set 'application/json'. Also I checked this by toy-project.

But I was confused, because our program used that content-type last years, and it did work.

I tried to figure out this, and I found this question.

[Solved] Teams Incoming Webhook: Bad payload received by generic incoming webhook

This case is very similar with our case.

I was wondering about, is there anything changed about Teams Incoming Webhook?
And if so, where I can found that?

Thanks.

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

Accepted answer
  1. Prasad-MSFT 9,061 Reputation points Microsoft External Staff Moderator
    2023-07-27T12:23:07.63+00:00

    양정우 [pororoca] - We got confirmation from engineering team that, "As per our docs, webhook messages should be of type JSON in HTTP POST headers: Create and send messages - Teams | Microsoft Learn".

    The old backend was allowing other content types as well, but in the new backend we have support for JSON only in line with our public documentation.

    Thanks, 

    Prasad Das

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Prasad-MSFT 9,061 Reputation points Microsoft External Staff Moderator
    2023-07-13T06:50:10.2133333+00:00

    양정우 [pororoca]
    We tried using below JSON

    {
        "@type": "MessageCard",
        "@context": "http:\/\/schema.org\/extensions",
        "themeColor": "d58200",
        "title": "title",
        "text": "text",
        "potentialAction": [
            {
                "@type": "OpenUri",
                "name": "Name",
                "targets": [
                    {
                        "os": "default",
                        "uri": "https:\/\/www.example.com\/"
                    }
                ]
            }
        ]
    }
    

    User's image

    and observed that the card is getting posted successfully in Teams channel.
    User's image

    Did you try adding the following header to the request and check if it works?

    Content-Type: application/json

    Thanks, 

    Prasad Das

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link.

    1 person found this answer helpful.

  2. Prasad-MSFT 9,061 Reputation points Microsoft External Staff Moderator
    2023-07-13T06:46:53.9933333+00:00


    양정우 [pororoca]

    We tried with below JSON

    {
        "@type": "MessageCard",
        "@context": "http:\/\/schema.org\/extensions",
        "themeColor": "d58200",
        "title": "title",
        "text": "text",
        "potentialAction": [
            {
                "@type": "OpenUri",
                "name": "Name",
                "targets": [
                    {
                        "os": "default",
                        "uri": "https:\/\/www.example.com\/"
                    }
                ]
            }
        ]
    }
    
    

    and observed that the card is getting posted successfully in Teams channel.
    User's image

    Did you try adding the following header to the request and check if it works?
    Content-Type: application/json

    Thanks, 

    Prasad Das

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link.

    0 comments No comments

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.