i am getting issue while running the below relevance code to find out the result of an bigfix action
via - Debug - Presentation debugger getting correct result
(ids of actions of it, names of computers of it, detailed statuses of it) of results of bes action whose (id of it = 26522) ; (IDs of item 0 of it , Names of item 1 of it , "Not Reported") of (elements of (set of targeted computers of it - set of computers of results of it) , it) of bes actions whose (id of it = 26522)
26522, LP1-AP-52117398, Not Reported
via - Postman rest api call - error message
https://server1:52311/api/query?output=json&relevance=(ids of actions of it, names of computers of it, detailed statuses of it) of results of bes action whose (id of it = 26522) ; (IDs of item 1 of it , Names of item 1 of it , "Not Reported") of (elements of (set of targeted computers of it - set of computers of results of it) , it) of bes actions whose (id of it = 26522)
**{"result":[],"plural":true,"type":"( integer, string, string )","evaltime_ms":2}**
I’m not real familiar with Postman, but it looks like a problem with your Postman setup. You probably need an option to URL-encode your query, or possibly URL-encode it before you enter the query on Postman.
1 Like
Exactly, need URL-encode the relevance expression …
This is for example how simply request 'number of bes computers’
https://myserver:52311/api/query?relevance=number%20of%20bes%20computers
Several way to URL-encode an URI, online or using tools. Just the first examples have found online:
2 Likes
i updated the powershell code with url encoding option and it worked
thanks for all yoru suggestions.
$url = 'https://server1:52311/api/query?output=json&relevance=(ids of actions of it, names of computers of it, detailed statuses of it) of results of bes action whose (id of it = 26554) ; (IDs of item 1 of it , Names of item 0 of it , "Not Reported") of (elements of (set of targeted computers of it - set of computers of results of it) , it) of bes actions whose (id of it = 26554)'
$encodedUrl = [System.Uri]::EscapeUriString($url)
Write-Host "Encoded URL: $encodedUrl"
1 Like
Final Version
$code= @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) {
return true;
}
}
"@
Add-Type -TypeDefinition $code -Language CSharp
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic YmlnZml4X2FkbWluOkFkbWluMDk4IQ==")
$headers.Add("Cookie", "SessionToken=`"I68SIlYZv1y35HkBmWWkgYfersZ6oElbDG8zRnnswpL+HBND2yUChQx5RJWnkoFWKBQilh/O+4Kbo5qoC9Ut6g==`"")
$url = '(ids of actions of it, names of computers of it, detailed statuses of it) of results of bes action whose (id of it = 26554) ; (IDs of item 1 of it , Names of item 0 of it , "Not Reported") of (elements of (set of targeted computers of it - set of computers of results of it) , it) of bes actions whose (id of it = 26554)'
$encodedUrl = [System.Uri]::EscapeDataString($url)
Write-Host "Encoded URL: $encodedUrl"
$str="https://server1:52311/api/query?output=json&relevance="
$finalurl=$str+"($encodedUrl)"
$finalurl
$response = Invoke-RestMethod $finalurl -Method 'GET' -Headers $headers
$response| ConvertTo-Json
1 Like