如何使用HTTP Post传递参数给运行簿?

huangapple go评论63阅读模式
英文:

How to pass a parameter to a runbook using HTTP Post?

问题

I was having problems passing some variables in a powershell script/runbook/webhook via a post http call so I thought I would find a much simpler script and try, but its still the same so I’m obviously doing something wrong. Here is the powershell script/runbook which I’m calling via a webook:

Param
(
  [Parameter (Mandatory= $true)]
  [String] $Name
)

## Hello 
write "Hello $Name"

This is my basic test flow

如何使用HTTP Post传递参数给运行簿?

I just cant seem to wrap my head around the formatting that is required and I've tried to many variations that I'm starting to get lost. Here are a few other screenshots that might be useful:

如何使用HTTP Post传递参数给运行簿?

如何使用HTTP Post传递参数给运行簿?

如何使用HTTP Post传递参数给运行簿?

Since the script has "[Parameter (Mandatory= $true)] [String] $Name" it prompts you to enter a:

"a default value which would be used if no specific value is entered instead."

during the creation of the Webhook, I tried removing this as well but then it just says "Hello" and still ignores any value I put in my PA flow.

I must be doing something so stupid but if I can get this simple example working I can implement the same formatting over to my more complicated (well complicated for me) project and continue working away.

Thanks for any help or advice.

Tried to pass some parameters over to a powershell script/runbook via a webhook but it doesnt seem to work.

英文:

I was having problems passing some variables in a powershell script/runbook/webhook via a post http call so I thought I would find a much simpler script and try, but its still the same so I’m obviously doing something wrong. Here is the powershell script/runbook which I’m calling via a webook:

Param
(
  [Parameter (Mandatory= $true)]
  [String] $Name
)

## Hello 
write "Hello $Name"

This is my basic test flow

如何使用HTTP Post传递参数给运行簿?

I just cant seem to wrap my head around the formatting that is required and I've tried to many variations that I'm starting to get lost. Here are a few other screenshots that might be useful:

如何使用HTTP Post传递参数给运行簿?

如何使用HTTP Post传递参数给运行簿?

如何使用HTTP Post传递参数给运行簿?

Since the script has " [Parameter (Mandatory= $true)] [String] $Name" it prompts you to enter a:

"default value which would be used if no specific value is entered instead".

during the creation of the Webhook, I tried removing this as well but then it just says "Hello" and still ignores any value I put in my PA flow.

 

I must be doing something so stupid but if I can get this simple example working I can implement the same formatting over to my more complicated (well complicated for me) project and continue working away.

 

Thanks for any help or advice.

Tried to pass some parameters over to a powershell script/runbook via a webhook but it doesnt seem to work.

答案1

得分: 0

由于运行簿的输入是通过请求主体传入的,您需要在脚本中进行以下更改以获得所需的输出。

param (
    [Parameter (Mandatory = $false)]
    [object] $WebHookData
)

Write-Output "你好 $WebHookData.RequestBody"

以下是我通过逻辑应用发送的示例请求。

"Rambo"

结果:

在运行簿中:

在逻辑应用中:

英文:

Since the input to the runbook is coming through request body you need to do below changes in your script to get the desired output.

param (
    [Parameter (Mandatory = $false)]
    [object] $WebHookData
)


write Hello $WebHookData.RequestBody

如何使用HTTP Post传递参数给运行簿?

Below is the sample request that I'm sending through my logic apps.

"Rambo"

如何使用HTTP Post传递参数给运行簿?

Results:

In Runbook:

如何使用HTTP Post传递参数给运行簿?

In LogicApp:

如何使用HTTP Post传递参数给运行簿?

huangapple
  • 本文由 发表于 2023年2月24日 04:00:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75549750.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定