Hi @Gaurav Garg ,
As explained here, for the WebhookData
parameter in the UI for testing in Test pane of the runbook, you must pass the data in JSON object with carriage returns and newline characters, so it matches the format that is passed in from a webhook.
For example, pass the following sample JSON object in the UI for the WebhookData
parameter for a sample runbook shared below.
{"WebhookName":"mywebhook","RequestBody":"[\r\n {\r\n "ResourceGroup": "rg01",\r\n "Name": "vm01"\r\n },\r\n {\r\n "ResourceGroup": "rg02",\r\n "Name": "vm02"\r\n }\r\n]"}
param
(
[Parameter (Mandatory=$true)]
[object] $WebhookData
)
# Logic to allow for testing in Test pane
if (-Not $WebhookData.RequestBody) {
$WebhookData = (ConvertFrom-Json -InputObject $WebhookData)
Write-Output "test1 $WebhookData"
Write-Output "test2"
Write-Output $WebhookData.RequestBody
Write-Output "test3"
Write-Output $WebhookData.RequestHeader
Write-Output "test4"
Write-Output $WebhookData.RequestHeader.header1
}
For illustration, check below screenshots of runbook execution and output. Note that in this example RequestHeader and header1 under RequestHeader is not showing any output as the input JSON object doesn't have those related details. So, based on the use case you might have to provide input JSON object in the required format with carriage returns and newline characters, so it matches the format that is passed in from a webhook.
In the real-time scenario, request body of the incoming POST request of webhook parameter can keep any data formatting such as string, JSON, XML, or form-encoded. The runbook must be written to work with the data format that is expected.