0

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

enter image description here

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:

enter image description here

enter image description here

enter image description here

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.

f2_
  • 13
  • 5
  • Go back and just use PS, Read the website manual. Each website is different. Parameter to a server can be set three ways 1) In the URI 2) As HTTP Headers 3) In the body (POST). Server will give errors if you send data that is not correctly formatted and is in the format that the server wants. – jdweng Feb 24 '23 at 11:21
  • Yeah maybe its a bit of an odd setup, I just wanted to go down this route for simplifying the account create process but got stuck towards the end lol. Thankfully I managed to understand SwethaKandikonda's answer and got it working at my end. Thanks for the reply. – f2_ Feb 27 '23 at 15:32

1 Answers1

0

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

enter image description here

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

"Rambo"

enter image description here

Results:

In Runbook:

enter image description here

In LogicApp:

enter image description here

SwethaKandikonda
  • 7,513
  • 2
  • 4
  • 18
  • That worked a treat! I found this MS article talking about "WebhookData" that might be useful to others searching for this problems: https://learn.microsoft.com/en-us/azure/automation/automation-webhooks?tabs=portal I also managed to add multiple values so I can use it in another flow where that is needed, however I'm not 100% its correct or there is a better way to do it. Either way, really appreciate you taking time to do all that work and create a similar setup to mine. I was going round in circles with this one, I can think of tons ways I can reuse this for other flows/logicapps etc. – f2_ Feb 27 '23 at 15:27
  • I cant upvote your answer since I don’t have 15 reputation points but I have marked it as answered. – f2_ Feb 27 '23 at 15:33