无法从服务挂钩的事件中获取几乎所有信息

Can't get almost all information from event from service Hook

我正在尝试将 Trello 服务挂钩与 Team Foundation Server 结合使用。我有 followed this tutorial 并且连接正常工作,但是我无法从事件 JSON 中获得我需要的信息: The Description I Tried

这是活动 JSON:

{
    "id": "03c164c2-8912-4d5e-8009-3707d5f83734",
    "eventType": "git.push",
    "publisherId": "tfs",
    "scope": 0,
    "message": {
        "text": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.",
        "html": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.",
        "markdown": "Jamal Hartnett pushed updates to `Fabrikam-Fiber-Git`:`master`."
    },
    "detailedMessage": {
        "text": "Jamal Hartnett pushed a commit to Fabrikam-Fiber-Git:master.\n - Fixed bug in web.config file 33b55f7c",
        "html": "Jamal Hartnett pushed a commit to <a href=\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/\">Fabrikam-Fiber-Git</a>:<a href=\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/#version=GBmaster\">master</a>.\n<ul>\n<li>Fixed bug in web.config file <a href=\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74\">33b55f7c</a>\n</ul>",
        "markdown": "Jamal Hartnett pushed a commit to [Fabrikam-Fiber-Git](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/):[master](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/#version=GBmaster).\n* Fixed bug in web.config file [33b55f7c](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74)"
    },
    "resource": {
        "commits": [
            {
                "commitId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74",
                "author": {
                    "name": "Jamal Hartnett",
                    "email": "fabrikamfiber4@hotmail.com",
                    "date": "2015-02-25T19:01:00Z"
                },
                "committer": {
                    "name": "Jamal Hartnett",
                    "email": "fabrikamfiber4@hotmail.com",
                    "date": "2015-02-25T19:01:00Z"
                },
                "comment": "Fixed bug in web.config file",
                "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74"
            }
        ],
        "refUpdates": [
            {
                "name": "refs/heads/master",
                "oldObjectId": "aad331d8d3b131fa9ae03cf5e53965b51942618a",
                "newObjectId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74"
            }
        ],
        "repository": {
            "id": "278d5cd2-584d-4b63-824a-2ba458937249",
            "name": "Fabrikam-Fiber-Git",
            "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249",
            "project": {
                "id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
                "name": "Fabrikam-Fiber-Git",
                "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
                "state": "wellFormed",
                "visibility": "unchanged"
            },
            "defaultBranch": "refs/heads/master",
            "remoteUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git"
        },
        "pushedBy": {
            "id": "00067FFED5C7AF52@Live.com",
            "displayName": "Jamal Hartnett",
            "uniqueName": "Windows Live ID\fabrikamfiber4@hotmail.com"
        },
        "pushId": 14,
        "date": "2014-05-02T19:17:13.3309587Z",
        "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/pushes/14"
    },
    "resourceVersion": "1.0",
    "resourceContainers": {
        "collection": {
            "id": "c12d0eb8-e382-443b-9f9c-c52cba5014c2"
        },
        "account": {
            "id": "f844ec47-a9db-4511-8281-8b63f4eaf94e"
        },
        "project": {
            "id": "be9b3917-87e6-42a4-a549-2bc06a7a878f"
        }
    },
    "createdDate": "2017-07-21T16:48:44.312Z"
}

这是发送给 Trello 的请求:

Method: POST
URI: https://api.trello.com/1/cards?key=7d6630fd03ac2b6fc9fde2f2ef0c4096&token=********
HTTP Version: 1.1
Headers:
{
  Content-Type: application/json; charset=utf-8
}
Content:
{
  "name": "Test Nº  ",
  "desc": "Description: ",
  "pos": "top",
  "due": null,
  "labels": "green",
  "idList": "5935a0d45ff8e5a6c8f828b9"
}

我可以从事件 JSON 中 get/read 的唯一字段是 "message"。

我做错了什么?

更新

Eddie 是对的,在这种情况下您应该使用 push 作为资源。文档不是很清楚。最后,它是如此简单。然而,相应的 checkin 不适用于 Code checked in 事件。

文档绝对可以更清楚地说明每个事件的资源是如何应用的,以帮助避免这种混淆。


The basic form of the placeholder is {{resource.field}} where resource is the name of the resource raising the event (workitem, build, etc) and field is a field within the resource section of the event, like id. So, if the subscription were for a completed build, it might be something like:

Build {{build.id}} completed at {{build.finishTime}}

看来问题是您在这种情况下使用了错误的占位符。根据您发送的 Request , resource.pushID & resource.commits.[0].comment 不会被引发事件的值替换。

如需获取推送ID和评论,说明为:

{{push.pushId}}

{{push.commits[0].comment}}