Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Having trouble updating insight from a script

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 14, 2022

Hi all,

I am getting a weird error when updating insight from Azure AD, even though the records are being updated I am getting an error.  This error is impacting when I find a matching record also (based on a name).

Here is the error

Invoke-RestMethod : {"errorMessages":["IQL \"Name = Lee Gu\" has invalid syntax at position 11 with error message \"mismatched input 'G' expecting {, ' 
'}\""],"errors":{}}
At C:\Users\Steven-Admin\Desktop\AddToInsight.ps1:138 char:15
+ ... $result = Invoke-RestMethod -Method Post -Headers $headers -Uri $ur ...

 

Here is what is getting logged

[2022-09-15 15:44:08] Name = Lee Gu
[2022-09-15 15:44:08] {
"objectSchemaId": 5,
"objectTypeId": 24,
"resultsPerPage": 1,
"iql": "Name = Lee Gu"
}

 

Here is what I see when I check the data variable

PS C:\Windows\system32> $data


AD_Name AD_Country
------- ----------
@{name=Name; id=99; value=Lee Gu} @{name=Country; id=448; value=United States}

 

I am assuming this part if what is wrong, but not sure how to fix it

"Name = Lee Gu"

 

I am building the IQL like this

 

$key = $data.AD_Name

$iql = $key.name + ' = ' + $key.value

$url = "https://api.atlassian.com/jsm/insight/workspace/$workspaceId/v1/object/navlist/iql"

$headers = @{
'Authorization' = "Basic $token"
'Content-Type' = 'application/json'
'Accept' = 'application/json'
}

$resultsPerPage = 1

$body = [PSCustomObject]@{
objectSchemaId = $objectSchemaId
objectTypeId = $objectTypeId
resultsPerPage = $resultsPerPage
iql = $iql
} | ConvertTo-Json

$result = Invoke-RestMethod -Method Post -Headers $headers -Uri $url -Body $body

 

Not sure how to fix this

1 answer

1 accepted

3 votes
Answer accepted
Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2022

Azure AD has a unique ID field.. no spaces, so no problem.  Insight is getting new users created from Azure and updating information for existing users.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events