Link to home
Start Free TrialLog in
Avatar of sbornstein2
sbornstein2

asked on

Anyone know how to invoke a Rest Web API from a powershell script?

Hey all,

So I am clueless with Powershell.   Not even sure how to run this powershell file after I create it.   I simply need to invoke a Web API call somehow from a script and someone told me powershell can do this.   Any example on how to do this if I give it the URL such as:

http://localhost:51828/api/Customer/Generate

Then if someone can tell me how to invoke assuming I have powershell installed on my machine.

Thanks all.
ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A couple other options.  If you don't know anything about PowerShell then I don't know how helpful they will be since it only gets you started.  Depending on what is returned by the request the next steps vary.

$result = Invoke-WebRequest -Uri "http://localhost:51828/api/Customer/Generate"

# or

$url = "http://localhost:51828/api/Customer/Generate"
$result = Invoke-RestMethod -URI $url -Method GET

# now look at the contents of $result

Open in new window

Avatar of sbornstein2
sbornstein2

ASKER

tx