API User's Guide
PowerShell: Obtaining information about objects, user authentication
Introduced in 8.7
Updated in 2021.1
You can use PowerShell scripts to retrieve information about specific Alloy Navigator objects using a GET query. The script below retrieves all fields for the object with ID = T000027. User authentication is used.
Copy the script and replace the placeholders with your actual API UR L and the credentials of an Alloy Navigator technician account.
NOTE: To get the proper output, make sure that the ticket T000027 exists in your database; otherwise, replace the sample ID with the ID of any other existing ticket or another Alloy Navigator object.
$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' = 'client_credentials'; 'client_id' = $clientId; 'client_secret' = $clientSecret; }
$htmlResponse = Invoke-WebRequest -UseBasicParsing -Uri "$ApiUrl/token" -Method POST -Body $postParams
$token = (ConvertFrom-Json $htmlResponse.Content).access_token
$HtmlResponse = Invoke-WebRequest -UseBasicParsing -Uri "$ApiUrl/object/T000027" `
-Method GET `
-Headers @{ 'authorization' = "bearer $token"; 'content-type' = 'application/json'; }
$htmlResponse