Hi there,
I am trying to build a little powershell script just to pull out some information from Assets.
Below is part of the code I am using to try and build out the GET but I keep getting an error that is show below. If I remove the $encodedQuery after the qlQuery= the whole thing works fine but I get EVERYTHING.
$objectSchema = "IT Assets"
$objectType = "IT Hardware"
# Remove the space before URL-encoding the query string
$encodedQuery = [System.Web.HttpUtility]::UrlEncode("objectSchema='$objectSchema' AND objectType='$objectType'")
$assetUrl = "https://api.atlassian.com/jsm/assets/workspace/$jira_workspace_id/v1/aql/objects?qlQuery=($encodedQuery)"
$response = Invoke-RestMethod -Uri $assetUrl -Headers $JiraHeaders -Method GET
Invoke-RestMethod : {"errorMessages":["AQL \"(objectSchema='IT Assets')\" has invalid syntax at position 18 with error message \"no viable alternative at input '(objectSchema='IT A'\""],"errors":{}}
At line:27 char:13
+ $response = Invoke-RestMethod -Uri $assetUrl -Headers $JiraHeaders -M ...
Next challenge will be just exporting the name and display value to CSV but I can't get past this query issue first.
At the risk of stating the obvious, it's getting hung up "IT" having "assets" after it. It seems to accept that the string 'IT Assets' have quotes around it but it just doesn't like "assets" coming after "IT".
My advice is to use CURL or Postman to do the call and THEN translate it into the right Powershell syntax once you get the right return value.
Dave
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.