API User's Guide

PowerShell: Retrieving objects (POST)

Introduced in 8.7

Updated in 2021.1

You can use PowerShell scripts to retrieve information about Alloy Navigator objects using a POST query. The script below retrieves a list of Incidents, filters them by the Status = In Progress condition, with no offset, and sorts the results by the Ticket field in descending order. These field values are returned: ID, Ticket. The script gets access to Alloy Navigator using user authentication.

Copy the script and replace the placeholders with your actual API URL and the credentials of an Alloy Navigator technician account.

$ApiUrl = 'https://API_URL'	# API URL without a trailing slash, i.e. https://example.com/api
$username = 'your_username'	# technician username
$password = 'your_password'	# technician password
$postParams = @{ 'grant_type' = 'password'; 'username' = $username; 'password' = $password; }
$htmlResponse = Invoke-WebRequest -UseBasicParsing -Uri "$ApiUrl/token" -Method POST -Body $postParams
$token = (ConvertFrom-Json $htmlResponse.Content).access_token
$htmlResponse = Invoke-WebRequest -UseBasicParsing -Uri "$ApiUrl/Incidents" `
	-Method POST `
	-Headers @{ 'authorization' = "bearer $token"; 'content-type' = 'application/json';  } `
	-Body @'
	"Fields": [
	"Filters": [
		"name": "Status",
		"value": "In Progress",
		"operation": "="
	"Sort": [
		"property": "Ticket",
		"direction": "desc"