Webhook - bad payload

Jay Mun 1 Reputation point
2021-12-14T00:43:20.847+00:00

Hi ,

I just don't get to sending a webhook message.

I tried to set a variable and put to data field and send but kept failing due to "bad payload"

seems like inserting a variable is not available or i did wrong way. I tried several ways. (\"$CHANNEL\" , $CHANNEL etc.)

here is my example code, please check this and feedback what i did wrong... thanks.

CHANNEL="This is a test code"

curl -d '{"context":"https://schema.org/extensions","type":"MessageCard","themeColor":"0072C6", "title":"Test","summary":"summary", "sections": [{ "facts" : [{ "name": "Channel" , "value" : "$CHANNEL" }]}]}' -H "Content-Type: Application/JSON" -X POST "webhookURL"

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
8,716 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,740 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hunaid Hanfee-MSFT 976 Reputation points
    2021-12-27T09:39:39.507+00:00

    I was able to send the Webhook by doing this -
    I tried using PowerShell and created a variable like below -> Given value inside double quote and value as 'Testing'

    PS C:\Windows\System32> $channel = "'Giving the variable as string and adding single quote inside it'"
    

    Then I created the payload to send this way, please have a look I changed all double quotes to single and given double quotes outside of it.

    PS C:\Windows\System32> $payload = "{'type':'MessageCard','themeColor':'0072C6', 'title':'Test','summary':'summary','text': 'We are testing payload', 'sections': [{ 'facts' : [{ 'name': 'Channel' , 'value' : $channel }]}]}"
    

    Lastly send the the webhook as follow

    PS C:\Windows\System32> curl.exe -H 'Content-Type: application/json' -d $payload $webhookURL
    

    It worked fine without any issue. Let us know by trying above code if it's working for you as well.

    Thanks,

    Hunaid L. Hanfee


    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.