Sofia Bo
Sofia Bo

Reputation: 779

Is there a way to make an API call from Azure runbook?

I have an automation account in Azure and I have a runbook in it. What I'm trying to do is to make an API call from this runbook. I'll need to login to some web service, get a session token and then use this session token to call some controller's methods.

So far I have only found some ways to call Azure runbooks through API (let's say from some backend c# code), but not vica versa. What I need to do is to call some c# methods FROM Azure runbook.

Is there a way to do it? If there is, how do I pass queries within my call? What I'm expecting to see is something like:

$response = MakeApiCall -Url "www.someurl.com" -Body "some json for example"

Upvotes: 0

Views: 4194

Answers (1)

Adam Marczak
Adam Marczak

Reputation: 2351

Yes you can.

It's either

$Url = "https://my-url"
$Body = @{
    field = "value"
}
Invoke-RestMethod -Method POST -Uri $url -Body $body -UseBasicParsing

or

Invoke-WebRequest

Invoke-RestMethod by default parses output, Invoke-WebRequest donesn't.

Upvotes: 4

Related Questions