Web hooks to Inbound Web Services

jonathanbyates
Mega Contributor

Hello World!

In the last week I have turned a lot of hair grey with the following issue.

I have WebHooks sending from TFS, but when it gets to SN it is creating a record in the correct table, with nothing in it. So I need to know what step I am missing here.

From the below I need to be parsing out the information in the "resource" group.

Web hook being sent

Method: POST

URI: https://mindyourownbusiness.service-now.com/u_project_tasks.do?WSDL

HTTP Version: 1.1

Headers:

{

  Authorization: Basic ********

  Content-Type: application/json; charset=utf-8

}

Content:

{

  "subscriptionId": "851e8aab-1e10-473f-986c-f00ac6cf61cf",

  "notificationId": 426,

  "id": "d2d46fb1-dba5-403c-9373-427583f19e8c",

  "eventType": "workitem.created",

  "publisherId": "tfs",

  "scope": "all",

  "message": {

      "text": "Bug #5 (Some great new idea!) created by Jamal Hartnett.\r\n(http://fabrikam-fiber-inc.visualstudio.com/web/wi.aspx?pcguid=74e918bf-3376-436d-bd20-8e8c1287f465&i...)"

  },

  "detailedMessage": {

      "text": "Bug #5 (Some great new idea!) created by Jamal Hartnett.\r\n(http://fabrikam-fiber-inc.visualstudio.com/web/wi.aspx?pcguid=74e918bf-3376-436d-bd20-8e8c1287f465&i... Area: FabrikamCloud\r\n- Iteration: FabrikamCloud\\Release 1\\Sprint 1\r\n- State: New\r\n- Assigned to: \r\n- Comment: \r\n- Severity: 3 - Medium\r\n"

  },

  "resource": {

      "id": 5,

      "rev": 1,

      "fields": {

          "System.AreaPath": "FabrikamCloud",

          "System.TeamProject": "FabrikamCloud",

          "System.IterationPath": "FabrikamCloud\\Release 1\\Sprint 1",

          "System.WorkItemType": "Bug",

          "System.State": "New",

          "System.Reason": "New defect reported",

          "System.CreatedDate": "2014-07-15T17:42:44.663Z",

          "System.CreatedBy": "Jamal Hartnett",

          "System.ChangedDate": "2014-07-15T17:42:44.663Z",

          "System.ChangedBy": "Jamal Hartnett",

          "System.Title": "Some great new idea!",

          "Microsoft.VSTS.Common.Severity": "3 - Medium",

          "WEF_EB329F44FE5F4A94ACB1DA153FDF38BA_Kanban.Column": "New"

      },

      "_links": {

          "self": {

              "href": "http://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/5"

          },

          "workItemUpdates": {

              "href": "http://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/5/updates"

          },

          "workItemRevisions": {

              "href": "http://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/5/revisions"

          },

          "workItemType": {

              "href": "http://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/ea830882-2a3c-4095-a53f-972f9..."

          },

          "fields": {

              "href": "http://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/fields"

          }

      },

      "url": "http://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/5"

  },

  "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-06-06T19:42:35.8237914Z"

}

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

6 REPLIES 6

jonathanbyates
Mega Contributor

Below is what I see in the Transaction Log. Bananas and Pineapple is the name of the instance.

SYSTEMHTTP authorizBananasAndPineappleon validated user 'jonathan.yates'
08:04.8InfoAPI_INT-thread-1SYSTEMSession user set to jonathan.yates
08:04.9InfoAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982#8614 /api/now/import/u_project_tasks Parameters -------------------------
api=api
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Processing REST Request /api/now/import/u_project_tasks
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Method:POST
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: content-type:applicBananasAndPineappleon/json; charset=utf-8
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: host:a.service-now.com
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: content-length:5136
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: expect:100-continue
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: x-forwarded-proto:https
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: x-forwarded-host:.service-now.com
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Request Header: x-forwarded-for:137.116.81.33
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RESTAPIProcessor : Pre-Service processing durBananasAndPineappleon durBananasAndPineappleon_micro_secs=45820
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] ServiceHandler : Service class: ImportSetAPIService
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] ServiceHandler : Resolving service method reference: create
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] ServiceHandler : Invoking service method
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] ImportSetAPIService : Inserting record
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RequestDeserializer : About to read request input stream
08:04.9DebugAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982DEBUG: #8614 [REST API] RequestDeserializer : Incoming Request Body:{"subscriptionId":"e9320607-38eb-4234-80fb-1752c9ee6fa1","notificBananasAndPineappleonId":2214,"id":"159408f2-1934-46ef-a47d-8813f1323e07","eventType":"workitem.updated","publisherId":"tfs","scope":"all","message":{"text":"Task #17330 (Investigate PBananasAndPineappleent Referral Pattern Analysis Query) transitioned to Closed by Benjamin Lugo\r\n(https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2...)","html":"<a href=\"https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2...\">Task #17330</a> (Investigate PBananasAndPineappleent Referral Pattern Analysis Query) transitioned to Closed by Benjamin Lugo","markdown":"[Task #17330](https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2...) (Investigate PBananasAndPineappleent Referral Pattern Analysis Query) transitioned to Closed by Benjamin Lugo"},"detailedMessage":{"text":"Task #17330 (Investigate PBananasAndPineappleent Referral Pattern Analysis Query) transitioned to Closed by Benjamin Lugo\r\n(https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2... New State: Closed\r\n","html":"<a href=\"https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2...\">Task #17330</a> (Investigate PBananasAndPineappleent Referral Pattern Analysis Query) transitioned to Closed by Benjamin Lugo<ul>\r\n<li>New State: Closed</li></ul>","markdown":"[Task #17330](https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2...) (Investigate PBananasAndPineappleent Referral Pattern Analysis Query) transitioned to Closed by Benjamin Lugo\r\n\r\n* New State: Closed\r\n"},"resource":{"id":10,"workItemId":17330,"rev":10,"revisedBy":{"id":"5fd0ed98-24ad-4570-8be9-7ab53999f974","name":"Benjamin Lugo <benjamin.lugo@BananasAndPineapple.com>","url":"https://app.vssps.visualstudio.com/Aab48823e-85f2-4202-b1b4-3e93609e2e94/_apis/Identities/5fd0ed98-2..."},"revisedDate":"9999-01-01T00:00:00Z","fields":{"System.Rev":{"oldValue":9,"newValue":10},"System.AuthorizedDate":{"oldValue":"2017-06-07T21:07:52.817Z","newValue":"2017-06-07T21:08:03.257Z"},"System.RevisedDate":{"oldValue":"2017-06-07T21:08:03.257Z","newValue":"9999-01-01T00:00:00Z"},"System.State":{"oldValue":"In Progress","newValue":"Closed"},"System.Reason":{"oldValue":"Moved out of state On Deck","newValue":"Moved out of state In Progress"},"System.ChangedDate":{"oldValue":"2017-06-07T21:07:52.817Z","newValue":"2017-06-07T21:08:03.257Z"},"System.Watermark":{"oldValue":131631,"newValue":131632},"Microsoft.VSTS.Scheduling.RemainingWork":{"oldValue":0.0},"Microsoft.VSTS.Common.StateChangeDate":{"oldValue":"2017-05-31T20:29:27.533Z","newValue":"2017-06-07T21:08:03.257Z"},"Microsoft.VSTS.Common.ClosedDate":{"newValue":"2017-06-07T21:08:03.257Z"}},"_links":{"self":{"href":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330/updates/10"},"workItemUpdates":{"href":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330/updates"},"parent":{"href":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330"},"html":{"href":"https://BananasAndPineapple.visualstudio.com/web/wi.aspx?pcguid=29342c97-cf91-490e-a297-a2dfad7560f2..."}},"url":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330/updates/10","revision":{"id":17330,"rev":10,"fields":{"System.AreaPath":"Dev\\Team Dry Needle","System.TeamProject":"Dev","System.IterBananasAndPineappleonPath":"Dev\\Dry Needle\\Sprint 22","System.WorkItemType":"Task","System.State":"Closed","System.Reason":"Moved out of state In Progress","System.AssignedTo":"Benjamin Lugo <benjamin.lugo@BananasAndPineapple.com>","System.CreatedDate":"2017-05-30T15:34:15.55Z","System.CreatedBy":"Lucy Sampson <lucy.jarvie@BananasAndPineapple.com>","System.ChangedDate":"2017-06-07T21:08:03.257Z","System.ChangedBy":"Benjamin Lugo <benjamin.lugo@BananasAndPineapple.com>","System.Title":"Investigate PBananasAndPineappleent Referral Pattern Analysis Query","Microsoft.VSTS.Scheduling.OriginalEstimate":4.0,"Microsoft.VSTS.Scheduling.CompletedWork":2.0,"Microsoft.VSTS.Common.Activity":"Development","Microsoft.VSTS.Common.StateChangeDate":"2017-06-07T21:08:03.257Z","Microsoft.VSTS.Common.ClosedDate":"2017-06-07T21:08:03.257Z","Microsoft.VSTS.Common.Priority":2},"relBananasAndPineappleons":[{"rel":"System.LinkTypes.Hierarchy-Reverse","url":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17021","attributes":{"isLocked":false}}],"_links":{"self":{"href":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330/revisions/10"},"workItemRevisions":{"href":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330/revisions"},"parent":{"href":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330"}},"url":"https://BananasAndPineapple.visualstudio.com/_apis/wit/workItems/17330/revisions/10"}},"resourceVersion":"1.0","resourceContainers":{"collection":{"id":"29342c97-cf91-490e-a297-a2dfad7560f2","baseUrl":"https://BananasAndPineapple.visualstudio.com/"},"account":{"id":"ab48823e-85f2-4202-b1b4-3e93609e2e94","baseUrl":"https://BananasAndPineapple.visualstudio.com/"},"project":{"id":"d0eeb9cc-866e-4d7b-9ae0-978a58ef33f5","baseUrl":"https://BananasAndPineapple.visualstudio.com/"}},"createdDate":"2017-06-07T21:08:04.9545868Z"}
08:04.9WarningAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982WARNING *** WARNING *** Get for non-existent record: planned_task:8ec0e590db9f32001c29d12c5e961951, initializing
08:04.9InfoAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982*** Script: PlannedTaskUtilsV2.restartChildren
08:04.9WarningAPI_INT-thread-102C0E590DB9F32001C29D12C5E961982WARNING *** WARNING *** Get for non-existent record: planned_task:8ec0e590db9f32001c29d12c5e961951, initializing
08:05.0Infoglide.record_watcher.evaluator.dd9fSYSTEMProcessed record # 626, queue size: 0, 1 second delay

nick_mooneyham
Kilo Contributor

Hey Jon,



Check out this article:


How to Integrate Webhooks Into ServiceNow



Let me know if that works!