Query to get a list of Objects and attribute data

Hello,

My goal is to query Jira Assets (Jira Service Management) for all Objects with a specific ID, return all attributes for those assets, and then later on process the data. But no matter the way I try, I can’t seem to query more than 25 results via AQL POST code.

Below is the snippet of the core functionality.

# === 1. AQL: ONLY schema 2 + SubVenue type ===
AQL="objectSchemaId = ${SCHEMA_ID} AND objectTypeId = ${SUBVENUE_TYPE_ID}"

echo "Running SubVenue debug AQL against Jira Assets:"
echo "  $AQL"
echo

start_index=0
per_page=200
total=0
declare -a subvenues=()

while true; do
    body=$(jq -n \
      --arg q "$AQL" \
      --argjson start "$start_index" \
      --argjson per  "$per_page" \
      '{
         qlQuery: $q,
         includeAttributes: false,
         startIndex: $start,
         resultPerPage: $per
       }')

    response=$(curl -s -u "$JIRA_USER:$JIRA_TOKEN" -X POST \
      "https://api.atlassian.com/jsm/assets/workspace/$WORKSPACE_ID/v1/object/aql" \
      -H "Content-Type: application/json" \
      -d "$body")

Hello @DanielBass

If you refer to the documentation for the POST /object/aql endpoint, you will see that there are no such parameters called resultPerPage or startIndex.

1 Like

Hi @sunnyape You are a life saver. That did the trick. So much for AI out there, humans still rule.

1 Like

I do love it when AIs apologise profusely for providing misleading or downright nonsense answers, then start explaining all the reasons why they gave that answer and how it’s not their fault! :smile:

Grok is by far the worse in the arrogance category haha. It says things like “100% this final code will work” and then goes to break 99.99% of the time :-p