S
Siddy Boy
Guest
I have created an Azure Function which gets triggered from service webhook created in Azure Devops. The values returned from this service hook to me are in the form of nested json.
{
"subscriptionId": "6ab9dc9a-f7cd-4e97-8288-1e1cca983e65",
"notificationId": 23,
"id": "8897cc21-8d79-4194-964f-6228f34e2a67",
"eventType": "workitem.updated",
"publisherId": "tfs",
"message": {
"text": "Product Backlog Item #9 (PBI B) updated by Siddharth Shailesh Mehta\r\n(https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9)",
"html": "<a href=\"https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9\">Product Backlog Item #9</a> (PBI B) updated by Siddharth Shailesh Mehta",
"markdown": "[Product Backlog Item #9](https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9) (PBI B) updated by Siddharth Shailesh Mehta"
},
"detailedMessage": {
"text": "Product Backlog Item #9 (PBI B) updated by Siddharth Shailesh Mehta\r\n(https://dev.azure.com/Sid-Demos/web...7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9)\r\n\r\n",
"html": "<a href=\"https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9\">Product Backlog Item #9</a> (PBI B) updated by Siddharth Shailesh Mehta<ul></ul>",
"markdown": "[Product Backlog Item #9](https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9) (PBI B) updated by Siddharth Shailesh Mehta\r\n\r\n"
},
"resource": {
"id": 10,
"workItemId": 9,
"rev": 6,
"revisedBy": {
"id": "2d3a6041-0cfc-4ec9-8b8b-65dbd3440fbf",
"name": "Siddharth Shailesh Mehta <mehta.siddharth87@gmail.com>",
"displayName": "Siddharth Shailesh Mehta",
"url": "https://spsprodsin1.vssps.visualstu...entities/2d3a6041-0cfc-4ec9-8b8b-65dbd3440fbf",
"_links": {
"avatar": {
"href": "https://dev.azure.com/Sid-Demos/_ap...wMTY2NjAtYWZhNy03YmUxLWJhMDMtMjc5MzkxMjVjOTE2"
}
},
"uniqueName": "mehta.siddharth87@gmail.com",
"imageUrl": "https://dev.azure.com/Sid-Demos/_ap...wMTY2NjAtYWZhNy03YmUxLWJhMDMtMjc5MzkxMjVjOTE2",
"descriptor": "msa.NWYwMTY2NjAtYWZhNy03YmUxLWJhMDMtMjc5MzkxMjVjOTE2"
},
"revisedDate": "9999-01-01T00:00:00Z",
"fields": {
"System.Rev": {
"oldValue": 5,
"newValue": 6
},
"System.AuthorizedDate": {
"oldValue": "2019-10-14T18:10:12.983Z",
"newValue": "2019-10-16T05:11:01.397Z"
},
"System.RevisedDate": {
"oldValue": "2019-10-16T05:11:01.397Z",
"newValue": "9999-01-01T00:00:00Z"
},
"System.ChangedDate": {
"oldValue": "2019-10-14T18:10:12.983Z",
"newValue": "2019-10-16T05:11:01.397Z"
},
"System.Watermark": {
"oldValue": 80,
"newValue": 84
},
"System.Description": {
"newValue": "<div><span>some trigger data added</span></div>"
}
},
"_links": {
"self": {
"href": "https://dev.azure.com/Sid-Demos/dd1...488499500d9a/_apis/wit/workItems/9/updates/10"
},
"workItemUpdates": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9/updates"
},
"parent": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9"
},
"html": {
"href": "https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9"
}
},
"url": "https://dev.azure.com/Sid-Demos/dd1...488499500d9a/_apis/wit/workItems/9/updates/10",
"revision": {
"id": 9,
"rev": 6,
"fields": {
"System.AreaPath": "PlanTrackWork",
"System.TeamProject": "PlanTrackWork",
"System.IterationPath": "PlanTrackWork\\Sprint 1",
"System.WorkItemType": "Product Backlog Item",
"System.State": "New",
"System.Reason": "New backlog item",
"System.CreatedDate": "2019-07-25T06:26:38.067Z",
"System.CreatedBy": "Siddharth Shailesh Mehta <mehta.siddharth87@gmail.com>",
"System.ChangedDate": "2019-10-16T05:11:01.397Z",
"System.ChangedBy": "Siddharth Shailesh Mehta <mehta.siddharth87@gmail.com>",
"System.CommentCount": 0,
"System.Title": "PBI B",
"System.BoardColumn": "New",
"System.BoardColumnDone": false,
"Microsoft.VSTS.Common.StateChangeDate": "2019-07-25T06:26:38.067Z",
"Microsoft.VSTS.Common.Priority": 2,
"Microsoft.VSTS.Common.ValueArea": "Business",
"Microsoft.VSTS.Scheduling.Effort": 9.0,
"Microsoft.VSTS.Common.BacklogPriority": 1999910559.0,
"WEF_4C46EB8309FF4FB5A75794E2B8352A68_Kanban.Column": "New",
"WEF_4C46EB8309FF4FB5A75794E2B8352A68_Kanban.Column.Done": false,
"System.Description": "<div><span>some trigger data added</span></div>",
"System.Parent": 15
},
"relations": [
{
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/15",
"attributes": {
"isLocked": false,
"name": "Parent"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/21",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/19",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/20",
"attributes": {
"isLocked": false,
"name": "Child"
}
}
],
"_links": {
"self": {
"href": "https://dev.azure.com/Sid-Demos/dd1...88499500d9a/_apis/wit/workItems/9/revisions/6"
},
"workItemRevisions": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9/revisions"
},
"parent": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9"
}
},
"url": "https://dev.azure.com/Sid-Demos/dd1...88499500d9a/_apis/wit/workItems/9/revisions/6"
}
},
"resourceVersion": "1.0",
"resourceContainers": {
"collection": {
"id": "4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a",
"baseUrl": "https://dev.azure.com/Sid-Demos/"
},
"account": {
"id": "62c35866-5d3b-48f1-a9e0-ec58dae1a44e",
"baseUrl": "https://dev.azure.com/Sid-Demos/"
},
"project": {
"id": "dd14a72e-8d38-4a99-ac1f-488499500d9a",
"baseUrl": "https://dev.azure.com/Sid-Demos/"
}
},
"createdDate": "2019-10-16T05:11:08.1690642Z"
}
I want to extract values from this nested Json like System.WorkItemType and System.WorkItemId.
I cannot convert this json to c# objects as the property name throws error on being named as System.WorkItemType or other variables. So I may need to escape them ( I guess)
So any help on how to extract these values from nested Json, would be great.
Thanks In Advance.
Continue reading...
{
"subscriptionId": "6ab9dc9a-f7cd-4e97-8288-1e1cca983e65",
"notificationId": 23,
"id": "8897cc21-8d79-4194-964f-6228f34e2a67",
"eventType": "workitem.updated",
"publisherId": "tfs",
"message": {
"text": "Product Backlog Item #9 (PBI B) updated by Siddharth Shailesh Mehta\r\n(https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9)",
"html": "<a href=\"https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9\">Product Backlog Item #9</a> (PBI B) updated by Siddharth Shailesh Mehta",
"markdown": "[Product Backlog Item #9](https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9) (PBI B) updated by Siddharth Shailesh Mehta"
},
"detailedMessage": {
"text": "Product Backlog Item #9 (PBI B) updated by Siddharth Shailesh Mehta\r\n(https://dev.azure.com/Sid-Demos/web...7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9)\r\n\r\n",
"html": "<a href=\"https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9\">Product Backlog Item #9</a> (PBI B) updated by Siddharth Shailesh Mehta<ul></ul>",
"markdown": "[Product Backlog Item #9](https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9) (PBI B) updated by Siddharth Shailesh Mehta\r\n\r\n"
},
"resource": {
"id": 10,
"workItemId": 9,
"rev": 6,
"revisedBy": {
"id": "2d3a6041-0cfc-4ec9-8b8b-65dbd3440fbf",
"name": "Siddharth Shailesh Mehta <mehta.siddharth87@gmail.com>",
"displayName": "Siddharth Shailesh Mehta",
"url": "https://spsprodsin1.vssps.visualstu...entities/2d3a6041-0cfc-4ec9-8b8b-65dbd3440fbf",
"_links": {
"avatar": {
"href": "https://dev.azure.com/Sid-Demos/_ap...wMTY2NjAtYWZhNy03YmUxLWJhMDMtMjc5MzkxMjVjOTE2"
}
},
"uniqueName": "mehta.siddharth87@gmail.com",
"imageUrl": "https://dev.azure.com/Sid-Demos/_ap...wMTY2NjAtYWZhNy03YmUxLWJhMDMtMjc5MzkxMjVjOTE2",
"descriptor": "msa.NWYwMTY2NjAtYWZhNy03YmUxLWJhMDMtMjc5MzkxMjVjOTE2"
},
"revisedDate": "9999-01-01T00:00:00Z",
"fields": {
"System.Rev": {
"oldValue": 5,
"newValue": 6
},
"System.AuthorizedDate": {
"oldValue": "2019-10-14T18:10:12.983Z",
"newValue": "2019-10-16T05:11:01.397Z"
},
"System.RevisedDate": {
"oldValue": "2019-10-16T05:11:01.397Z",
"newValue": "9999-01-01T00:00:00Z"
},
"System.ChangedDate": {
"oldValue": "2019-10-14T18:10:12.983Z",
"newValue": "2019-10-16T05:11:01.397Z"
},
"System.Watermark": {
"oldValue": 80,
"newValue": 84
},
"System.Description": {
"newValue": "<div><span>some trigger data added</span></div>"
}
},
"_links": {
"self": {
"href": "https://dev.azure.com/Sid-Demos/dd1...488499500d9a/_apis/wit/workItems/9/updates/10"
},
"workItemUpdates": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9/updates"
},
"parent": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9"
},
"html": {
"href": "https://dev.azure.com/Sid-Demos/web/wi.aspx?pcguid=4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a&id=9"
}
},
"url": "https://dev.azure.com/Sid-Demos/dd1...488499500d9a/_apis/wit/workItems/9/updates/10",
"revision": {
"id": 9,
"rev": 6,
"fields": {
"System.AreaPath": "PlanTrackWork",
"System.TeamProject": "PlanTrackWork",
"System.IterationPath": "PlanTrackWork\\Sprint 1",
"System.WorkItemType": "Product Backlog Item",
"System.State": "New",
"System.Reason": "New backlog item",
"System.CreatedDate": "2019-07-25T06:26:38.067Z",
"System.CreatedBy": "Siddharth Shailesh Mehta <mehta.siddharth87@gmail.com>",
"System.ChangedDate": "2019-10-16T05:11:01.397Z",
"System.ChangedBy": "Siddharth Shailesh Mehta <mehta.siddharth87@gmail.com>",
"System.CommentCount": 0,
"System.Title": "PBI B",
"System.BoardColumn": "New",
"System.BoardColumnDone": false,
"Microsoft.VSTS.Common.StateChangeDate": "2019-07-25T06:26:38.067Z",
"Microsoft.VSTS.Common.Priority": 2,
"Microsoft.VSTS.Common.ValueArea": "Business",
"Microsoft.VSTS.Scheduling.Effort": 9.0,
"Microsoft.VSTS.Common.BacklogPriority": 1999910559.0,
"WEF_4C46EB8309FF4FB5A75794E2B8352A68_Kanban.Column": "New",
"WEF_4C46EB8309FF4FB5A75794E2B8352A68_Kanban.Column.Done": false,
"System.Description": "<div><span>some trigger data added</span></div>",
"System.Parent": 15
},
"relations": [
{
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/15",
"attributes": {
"isLocked": false,
"name": "Parent"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/21",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/19",
"attributes": {
"isLocked": false,
"name": "Child"
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/20",
"attributes": {
"isLocked": false,
"name": "Child"
}
}
],
"_links": {
"self": {
"href": "https://dev.azure.com/Sid-Demos/dd1...88499500d9a/_apis/wit/workItems/9/revisions/6"
},
"workItemRevisions": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9/revisions"
},
"parent": {
"href": "https://dev.azure.com/Sid-Demos/dd14a72e-8d38-4a99-ac1f-488499500d9a/_apis/wit/workItems/9"
}
},
"url": "https://dev.azure.com/Sid-Demos/dd1...88499500d9a/_apis/wit/workItems/9/revisions/6"
}
},
"resourceVersion": "1.0",
"resourceContainers": {
"collection": {
"id": "4d93d7c6-f39c-4fcb-97c4-dd02654eaf3a",
"baseUrl": "https://dev.azure.com/Sid-Demos/"
},
"account": {
"id": "62c35866-5d3b-48f1-a9e0-ec58dae1a44e",
"baseUrl": "https://dev.azure.com/Sid-Demos/"
},
"project": {
"id": "dd14a72e-8d38-4a99-ac1f-488499500d9a",
"baseUrl": "https://dev.azure.com/Sid-Demos/"
}
},
"createdDate": "2019-10-16T05:11:08.1690642Z"
}
I want to extract values from this nested Json like System.WorkItemType and System.WorkItemId.
I cannot convert this json to c# objects as the property name throws error on being named as System.WorkItemType or other variables. So I may need to escape them ( I guess)
So any help on how to extract these values from nested Json, would be great.
Thanks In Advance.
Continue reading...