I have created a runbook that inserts a record in a SQL DB. I then created a webhook to invoke the runbook. The data for the record to insert is in the request body as JSON. However, when my runbook gets invoked by the webhook my WebhookData is null. The webhook should populate this object when it calls the runbook.
What gives?
Here's the pertinent content in the Runbook:
workflow MyRunbook
{
param(
[object] $WebhookData
)
inlinescript {
Write-Output "WebhookData $WebhookData"
$WebhookName = $WebhookData.WebhookName
$WebhookHeader = $WebhookData.RequestHeader
$WebhookBody = $WebhookData.RequestBody
$Params = ConvertFrom-Json -InputObject $WebhookBody
...
When I invoke the webhook from Fiddler I confirmed in the Azure dashboard that there is one Input: WEBHOOKDATA and the content looks correct. But the log from the run only shows: WebhookData [nothing]
Then there is an exception when trying to ConvertFrom-Json because WebhookBody is null.
Any ideas what is going wrong here?
Thanks in advance.
I figured it out.
I believe because of the 'inlinescript', any variables brought into the webhook have to be referenced with 'using'. So, here is my corrected code that is working now.
workflow MyRunbook
{
param(
[object] $WebhookData
)
inlinescript {
Write-Output "WebhookData $using:WebhookData"
...
This produced the expected response.