Original Message:
Sent: Tue February 20, 2024 08:50 AM
From: Pierre Dufresne
Subject: Accessing SOAR Rest API with Powershell
Hi Yohji,
Thank you so very much! It worked!
I just want to add for others who might use this code that on my first try I got this error message:
CategoryInfo : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
I just added this line at the beginning of the script:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Thanks again
------------------------------
Pierre Dufresne
------------------------------
Original Message:
Sent: Tue February 20, 2024 02:26 AM
From: Yohji Amano
Subject: Accessing SOAR Rest API with Powershell
Hi Pierre
How about to try the following code?
Before execution, you need to substitute the following parameters: <api-key>,<api-secret>, <soar-host>, <org-id> and <inc_id> according to your environments.
# BASIC Auth
$username = "<api-key>"
$password = "<api-secret>"
$basicAuthValue = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+":"+$password))
$headers = @{"Authorization" = $basicAuthValue}
# SOAR Info
$resilientIP = "<soar-host>"
$orgId = "<org-id>"
$incidentId = "<inc-id>"
# Incident REST-URL
$uri = "https://${resilientIP}/rest/orgs/${orgId}/incidents/${incidentId}"
# REST
Invoke-RestMethod -Uri $uri -Method Get -ContentType "application/json;" -Headers $headers
------------------------------
Yohji Amano