MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
287 stars 509 forks source link

Bad Payload when using Incoming Webhook from Github to Teams channel #10159

Closed danigirl329 closed 8 months ago

danigirl329 commented 10 months ago

Hello,

I am trying to set up a generic webhook from github to a teams channel. I can POST using Postman with simple json and with sample json but github's POSTs are failing with 400: Bad payload received by generic incoming webhook.

This is happening on the setup ping and creating new issues, etc.

Test ping that is failing from github:


{
  "zen": "Half measures are as bad as nothing at all.",
  "hook_id": 452801284,
  "hook": {
    "type": "Repository",
    "id": 452801284,
    "name": "web",
    "active": true,
    "events": [
      "push"
    ],
    "config": {
      "content_type": "json",
      "insecure_ssl": "0",
      "url": "https:...."
    },
    "updated_at": "2024-01-04T16:00:41Z",
    "created_at": "2024-01-04T16:00:41Z",
    "url": "https://api.github.com/repos/pgharts/culturaldistrict.org/hooks/452801284",
    "test_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/hooks/452801284/test",
    "ping_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/hooks/452801284/pings",
    "deliveries_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/hooks/452801284/deliveries",
    "last_response": {
      "code": null,
      "status": "unused",
      "message": null
    }
  },
  "repository": {
    "id": 35219925,
    "node_id": "MDEwOlJlcG9zaXRvcnkzNTIxOTkyNQ==",
    "name": "culturaldistrict.org",
    "full_name": "pgharts/culturaldistrict.org",
    "private": true,
    "owner": {
      "login": "pgharts",
      "id": 177398,
      "node_id": "MDEyOk9yZ2FuaXphdGlvbjE3NzM5OA==",
      "avatar_url": "https://avatars.githubusercontent.com/u/177398?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/pgharts",
      "html_url": "https://github.com/pgharts",
      "followers_url": "https://api.github.com/users/pgharts/followers",
      "following_url": "https://api.github.com/users/pgharts/following{/other_user}",
      "gists_url": "https://api.github.com/users/pgharts/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/pgharts/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/pgharts/subscriptions",
      "organizations_url": "https://api.github.com/users/pgharts/orgs",
      "repos_url": "https://api.github.com/users/pgharts/repos",
      "events_url": "https://api.github.com/users/pgharts/events{/privacy}",
      "received_events_url": "https://api.github.com/users/pgharts/received_events",
      "type": "Organization",
      "site_admin": false
    },
    "html_url": "https://github.com/pgharts/culturaldistrict.org",
    "description": "The Cultural District website project",
    "fork": false,
    "url": "https://api.github.com/repos/pgharts/culturaldistrict.org",
    "forks_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/forks",
    "keys_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/teams",
    "hooks_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/hooks",
    "issue_events_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/issues/events{/number}",
    "events_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/events",
    "assignees_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/assignees{/user}",
    "branches_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/branches{/branch}",
    "tags_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/tags",
    "blobs_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/languages",
    "stargazers_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/stargazers",
    "contributors_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/contributors",
    "subscribers_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/subscribers",
    "subscription_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/subscription",
    "commits_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/contents/{+path}",
    "compare_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/merges",
    "archive_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/downloads",
    "issues_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/issues{/number}",
    "pulls_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/labels{/name}",
    "releases_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/releases{/id}",
    "deployments_url": "https://api.github.com/repos/pgharts/culturaldistrict.org/deployments",
    "created_at": "2015-05-07T12:53:41Z",
    "updated_at": "2023-11-16T15:50:35Z",
    "pushed_at": "2024-01-03T16:55:08Z",
    "git_url": "git://github.com/pgharts/culturaldistrict.org.git",
    "ssh_url": "git@github.com:pgharts/culturaldistrict.org.git",
    "clone_url": "https://github.com/pgharts/culturaldistrict.org.git",
    "svn_url": "https://github.com/pgharts/culturaldistrict.org",
    "homepage": "",
    "size": 125484,
    "stargazers_count": 2,
    "watchers_count": 2,
    "language": "Ruby",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "has_discussions": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 275,
    "license": null,
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [

    ],
    "visibility": "private",
    "forks": 0,
    "open_issues": 275,
    "watchers": 2,
    "default_branch": "WIP",
    "custom_properties": {

    }
  },
  "sender": {
    "login": "danigirl329",
    "id": 10598969,
    "node_id": "MDQ6VXNlcjEwNTk4OTY5",
    "avatar_url": "https://avatars.githubusercontent.com/u/10598969?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/danigirl329",
    "html_url": "https://github.com/danigirl329",
    "followers_url": "https://api.github.com/users/danigirl329/followers",
    "following_url": "https://api.github.com/users/danigirl329/following{/other_user}",
    "gists_url": "https://api.github.com/users/danigirl329/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/danigirl329/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/danigirl329/subscriptions",
    "organizations_url": "https://api.github.com/users/danigirl329/orgs",
    "repos_url": "https://api.github.com/users/danigirl329/repos",
    "events_url": "https://api.github.com/users/danigirl329/events{/privacy}",
    "received_events_url": "https://api.github.com/users/danigirl329/received_events",
    "type": "User",
    "site_admin": false
  }
}
ChetanSharma-msft commented 10 months ago

Hello @danigirl329 - Thanks for raising your query. We will look into it and let you know the updates.

Vikram-MSFT commented 10 months ago

Hello @danigirl329 - Could you please share the repro steps for how to create this sample generic webhook ?

danigirl329 commented 10 months ago

Hello @Vikram-MSFT ! For creating a webhook for Github to Teams I did the following:

I created a Channel in Teams In the channel, i added an Incoming Webhook and copied the url it generated In github under the repository I went to Webhooks > Add I pasted the Teams URL into Payload URL and set it to "Just the push event" the Content Type is set to application/json Enable SSL Verification is true and Submitted (Add webhook)

Github sends a test ping to the webhook URL and it fails with the response 400 - Bad payload received by generic incoming webhook.

So what I did to test that it is working is I set up the url and headers in Postman and sent a simple payload like {"text":"Hello World"} and that works fine and I can see the text in the Channel.

I also want to mention that we use this github webhook to send to slack and other apps and it works fine so something on the teams side is rejecting the json.

Thanks!

Vikram-MSFT commented 10 months ago

Hello @danigirl329 we will investigate the issue and get back to you soon.

Vikram-MSFT commented 10 months ago

Hii @danigirl329 we are able to repro this issue, we will get back to you soon.

Vikram-MSFT commented 9 months ago

Hiii @danigirl329 We are also able to repro this issue, we will check internally and get back to you. Update : We raised a bug for this issue, we will keep you posted on the updates. Thank you

dougwperez commented 9 months ago

@Vikram-MSFT I am encountering the same exact bug as @danigirl329. Do we have any updates?

ChetanSharma-msft commented 9 months ago

Hello @danigirl329 & Others, We got an update from engineering team that this isn't a bug.

Incoming webhooks take payloads only in MessageCard or adaptive card format. The payload emitted by the GitHub webhook is NOT in that format.

You can either: 1) Use the webhook provided by the GitHub app, or 2) Write a small service that takes the data sent by the GitHub webhook, transforms it into an adaptive card, then posts the result to the URL generated by the incoming webhook.

dougwperez commented 9 months ago

@ChetanSharma-msft Thanks for the quick response! Can you elaborate a bit more on option 1?

wells commented 9 months ago

@ChetanSharma-msft It looks like this format used to be supported. Why was this support removed from Microsoft Teams?

And, why doesn't GitHub have an option for MessageCard / adaptive card format? GitHub is Microsoft now, after all.

nick-stemp commented 9 months ago

Seeing the same issues and would ask for this functionality to be added. A fair and well made point from wells.

georgiesamaha commented 9 months ago

+1

wells commented 9 months ago

Example of usage from article in June 2022: https://medium.com/sap-commerce-cloud/how-to-alerts-from-github-to-your-microsoft-teams-channel-8c476471a353

ChetanSharma-msft commented 8 months ago

Hello @Everyone - This issue is not related to Teams app development related query. Could you please post your GitHub Webhook issue related query here: https://docs.github.com/en/webhooks https://github.com/orgs/community/discussions/categories/api-and-webhooks

danigirl329 commented 8 months ago

Thanks for the update @ChetanSharma-msft .

Originally I was testing because the app for a channel "incoming webhooks" was failing with the github response. For anyone wondering, it looks like you can add a Github Connector and the cards do work. So I will close this.

Thanks

microsoft-github-policy-service[bot] commented 8 months ago

Tell us about your experience!

Hi danigirl329! This issue is closed in our system. We would like your feedback on your experience with our support team and Platform.

Best regards, Teams Platform

Wajeed-msft commented 6 months ago

danigirl329 - Could you please rotate your webhook URL as it's shared in public forum? Anyone with access to the webhook can post message in the channel.

Wajeed-msft commented 6 months ago

danigirl329 - Could you please rotate your webhook URL as it's shared in public forum? Anyone with access to the webhook can post message in the channel.

Wajeed-msft commented 5 months ago

danigirl329 - Could you please rotate your webhook URL as it's shared in public forum? Anyone with access to the webhook can post message in the channel.