我正在尝试在Taiga和Github之间建立一个Webhook,有效负载在下面,但是我得到的响应是:
{"_error_message": "The payload is not a valid json", "_error_type": "taiga.base.exceptions.BadRequest"}
这是有效载荷:
{
"zen": "Avoid administrative distraction.",
"hook_id": 58924287,
"hook": {
"type": "Repository",
"id": 58924287,
"name": "web",
"active": true,
"events": [
"*"
],
"config": {
"content_type": "form",
"insecure_ssl": "0",
"secret": "********",
"url": "https://api.taiga.io/api/v1/github-hook?project=291735"
},
"updated_at": "2018-10-24T23:40:03Z",
"created_at": "2018-10-24T23:40:03Z",
"url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks/58924287",
"test_url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks/58924287/test",
"ping_url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks/58924287/pings",
"last_response": {
"code": null,
"status": "unused",
"message": null
}
},
"repository": {
"id": 154575276,
"node_id": "MDEwOlJlcG9zaXRvcnkxNTQ1NzUyNzY=",
"name": "multivaria",
"full_name": "AncientSwordRage/multivaria",
"private": false,
"owner": {
"login": "AncientSwordRage",
"id": 5961746,
"node_id": "MDQ6VXNlcjU5NjE3NDY=",
"avatar_url": "https://avatars3.githubusercontent.com/u/5961746?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/AncientSwordRage",
"html_url": "https://github.com/AncientSwordRage",
"followers_url": "https://api.github.com/users/AncientSwordRage/followers",
"following_url": "https://api.github.com/users/AncientSwordRage/following{/other_user}",
"gists_url": "https://api.github.com/users/AncientSwordRage/gists{/gist_id}",
"starred_url": "https://api.github.com/users/AncientSwordRage/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/AncientSwordRage/subscriptions",
"organizations_url": "https://api.github.com/users/AncientSwordRage/orgs",
"repos_url": "https://api.github.com/users/AncientSwordRage/repos",
"events_url": "https://api.github.com/users/AncientSwordRage/events{/privacy}",
"received_events_url": "https://api.github.com/users/AncientSwordRage/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/AncientSwordRage/multivaria",
"description": "Multivariate Hypergeometric Probabilities (In Space!)",
"fork": false,
"url": "https://api.github.com/repos/AncientSwordRage/multivaria",
"forks_url": "https://api.github.com/repos/AncientSwordRage/multivaria/forks",
"keys_url": "https://api.github.com/repos/AncientSwordRage/multivaria/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/AncientSwordRage/multivaria/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/AncientSwordRage/multivaria/teams",
"hooks_url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks",
"issue_events_url": "https://api.github.com/repos/AncientSwordRage/multivaria/issues/events{/number}",
"events_url": "https://api.github.com/repos/AncientSwordRage/multivaria/events",
"assignees_url": "https://api.github.com/repos/AncientSwordRage/multivaria/assignees{/user}",
"branches_url": "https://api.github.com/repos/AncientSwordRage/multivaria/branches{/branch}",
"tags_url": "https://api.github.com/repos/AncientSwordRage/multivaria/tags",
"blobs_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/AncientSwordRage/multivaria/statuses/{sha}",
"languages_url": "https://api.github.com/repos/AncientSwordRage/multivaria/languages",
"stargazers_url": "https://api.github.com/repos/AncientSwordRage/multivaria/stargazers",
"contributors_url": "https://api.github.com/repos/AncientSwordRage/multivaria/contributors",
"subscribers_url": "https://api.github.com/repos/AncientSwordRage/multivaria/subscribers",
"subscription_url": "https://api.github.com/repos/AncientSwordRage/multivaria/subscription",
"commits_url": "https://api.github.com/repos/AncientSwordRage/multivaria/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/AncientSwordRage/multivaria/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/AncientSwordRage/multivaria/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/AncientSwordRage/multivaria/contents/{+path}",
"compare_url": "https://api.github.com/repos/AncientSwordRage/multivaria/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/AncientSwordRage/multivaria/merges",
"archive_url": "https://api.github.com/repos/AncientSwordRage/multivaria/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/AncientSwordRage/multivaria/downloads",
"issues_url": "https://api.github.com/repos/AncientSwordRage/multivaria/issues{/number}",
"pulls_url": "https://api.github.com/repos/AncientSwordRage/multivaria/pulls{/number}",
"milestones_url": "https://api.github.com/repos/AncientSwordRage/multivaria/milestones{/number}",
"notifications_url": "https://api.github.com/repos/AncientSwordRage/multivaria/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/AncientSwordRage/multivaria/labels{/name}",
"releases_url": "https://api.github.com/repos/AncientSwordRage/multivaria/releases{/id}",
"deployments_url": "https://api.github.com/repos/AncientSwordRage/multivaria/deployments",
"created_at": "2018-10-24T22:07:31Z",
"updated_at": "2018-10-24T23:00:16Z",
"pushed_at": "2018-10-24T23:00:14Z",
"git_url": "git://github.com/AncientSwordRage/multivaria.git",
"ssh_url": "git@github.com:AncientSwordRage/multivaria.git",
"clone_url": "https://github.com/AncientSwordRage/multivaria.git",
"svn_url": "https://github.com/AncientSwordRage/multivaria",
"homepage": null,
"size": 154,
"stargazers_count": 0,
"watchers_count": 0,
"language": "JavaScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 0,
"license": {
"key": "gpl-3.0",
"name": "GNU General Public License v3.0",
"spdx_id": "GPL-3.0",
"url": "https://api.github.com/licenses/gpl-3.0",
"node_id": "MDc6TGljZW5zZTk="
},
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "AncientSwordRage",
"id": 5961746,
"node_id": "MDQ6VXNlcjU5NjE3NDY=",
"avatar_url": "https://avatars3.githubusercontent.com/u/5961746?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/AncientSwordRage",
"html_url": "https://github.com/AncientSwordRage",
"followers_url": "https://api.github.com/users/AncientSwordRage/followers",
"following_url": "https://api.github.com/users/AncientSwordRage/following{/other_user}",
"gists_url": "https://api.github.com/users/AncientSwordRage/gists{/gist_id}",
"starred_url": "https://api.github.com/users/AncientSwordRage/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/AncientSwordRage/subscriptions",
"organizations_url": "https://api.github.com/users/AncientSwordRage/orgs",
"repos_url": "https://api.github.com/users/AncientSwordRage/repos",
"events_url": "https://api.github.com/users/AncientSwordRage/events{/privacy}",
"received_events_url": "https://api.github.com/users/AncientSwordRage/received_events",
"type": "User",
"site_admin": false
}
}
(我认为那里没有什么秘密)
Taiga为什么报告这是无效的(我已经检查了-不是)?
答案 0 :(得分:1)
在github端,检查如何为您的hook配置content-type。 看起来它是Form-Url编码的(在显示的有效负载中:
...
"content_type": "form".
...
)
确保已按照taiga的要求将其配置为application / json。
是的,当您查看github端的有效负载时,即使将其作为Form发送,它也会将其显示为JSON。