Json 带有来自httpClient的参数的Azure Runbook Webhook
看了几个示例,说明如何使用参数执行webhook,但似乎无法连接到我所缺少的内容。任何关于我做错了什么的建议都将不胜感激 请考虑: 我的Powershell运行手册Json 带有来自httpClient的参数的Azure Runbook Webhook,json,powershell,runbook,Json,Powershell,Runbook,看了几个示例,说明如何使用参数执行webhook,但似乎无法连接到我所缺少的内容。任何关于我做错了什么的建议都将不胜感激 请考虑: 我的Powershell运行手册 [CmdletBinding()] Param([object]$WebhookData) #this parameter name needs to be called WebHookData otherwise the webhook does not work as expected. $VerbosePreference
[CmdletBinding()]
Param([object]$WebhookData) #this parameter name needs to be called
WebHookData otherwise the webhook does not work as expected.
$VerbosePreference = 'continue'
Write-Output "hello"
"in the inline"
if($WebhookData -ne $null)
{
"using webhookdata"
$WebhookName = $WebhookData.WebhookName
$WebhookBody = $WebhookData.RequestBody
$webhookBodyObject = $WebhookBody | ConvertFrom-JSON
line 15 'The parameter created was ' $webhookBodyObject.strYear
我的httpclient post请求如下所示(警告..它是vb)
我的Webhook数据正在以如下方式发布到我的Webhook
{"WebhookName":"myimportjob","RequestBody":"{'strYear'='2018'}","RequestHeader":{"Connection":"Keep-Alive","Expect":"100-continue","Host":"xxx.azure-automation.net","x-ms-request-id":"xxx"}}
我得到了这个错误
第15行字符:42
+'创建的参数为'$webhookBodyObject.strYear'
+~~~~~~~~~~~~~~~~~~~~~~~表达式或中出现意外标记“$webhookBodyObject”
声明
我发现魔鬼就在细节中。 首先我有
$webhookBodyObject = $WebhookBody | ConvertFrom-JSON
这和
$webhookBodyObject = $WebhookBody | ConvertFrom-Json <---this is the correct syntax
$webhookBodyObject=$WebhookBody | convertfromjson我还尝试将我的Json更改为dim WebHookData作为新的StringContent(“{”strYear“:“2018”}),Encoding.UTF8,“application/Json”),结果是webhookname={”webhookname:“RunImportOnDev”,“RequestBody:“{”strYear\:“2018\”,"请求…那么如果您注释掉第15行,您的runbook执行时是否没有错误?我觉得这似乎是powershell语法错误。您发布的runbook代码不完整,因此无法查看是否缺少某些内容。您好。它将运行,但我需要在实际代码中进一步使用参数。我没有粘贴其他代码,因为我没有粘贴其他代码将其视为有价值的,因为错误似乎是它无法获取该参数。如果您对其进行了注释,并且成功了,那么我猜这只是一个Powershell语法错误。该错误是在保存Powershell时发生的还是在调用它时发生的?
$webhookBodyObject = $WebhookBody | ConvertFrom-Json <---this is the correct syntax