Jump to content

Rest API authentication / Convert Powershell Script

Recommended Posts



i'm trying to authenticate to REST API but cannot find anything in the forums to match exact scenario - there's a working powershell script but want to utilize autoit instead and i believe could utilize wingethttp to achive this? and once authenticated can send multiple queries thereafter?:

working powershell script:

$server = "SERVER"
$user = "API USER"

$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }

$url = "https://${server}:2616/api/1/oprule/rule/${RuleID}/device/group/${GroupID}?activation=manual"
$object = Invoke-RestMethod -Method PUT -Uri $url -Headers $headers
$object.assignment.id #Will display the assignment ID



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now