How to find with Object Type in Assets has Total unique constraints per object type higher then 2?
You can do it manually, but this may be a tedious task: you have to select each single attribute of an object type definition and check "three dots"->Configuration->General whether the "unique" checkbox is checked (= unique constraint) or not. If more than two attributes have been marked as unique, you have to uncheck at least one.I have written a program (using C#, legacy .NET Framework 4.8; should work with modern .NET as well) against the Assets REST-API (The Assets REST API). First, the app reads and stores all available schemes (use GET .../objectschema/list). Then, it extracts for each schema all object types (use GET .../objectschema/{id}/objecttypes) and stores them in lists (actually, you just need the id and the name for each object type). Then, it reads the list of object type attributes für each object type (use GET .../objecttype/{id}/attributes). Finally, it loops through these lists and sums up (for each object type) the number of cases where the value of the "uniqueAttribute" is true. In my case, the result looks like this (I could have listed the "unique" attributes as well, but it was not required in our case; however, if your object types are rather big, this might still be useful):
I have designed a workflow in Postman using the Assets REST API to retrieve and display the count of unique attributes from each schema, as shown in the image below. The logic remains the same.
Nice.
Designing a workflow in Postman requires significant time, effort, and experience. To simplify the process, I have written a Bash script that produces the same results.
#!/bin/bash
# Set API detailsWORKSPACE_ID="your-workspace-id" # Replace with your Atlassian workspace IDAPI_TOKEN="your-api-token"
# Atlassian Assets API Base URLBASE_URL="https://api.atlassian.com/jsm/assets/workspace/$WORKSPACE_ID/v1"
# Headers for authenticationAUTH_HEADER="-H Authorization: Bearer $API_TOKEN"CONTENT_HEADER="-H Content-Type: application/json"
# Temporary file to store resultsOUTPUT_FILE="unique_attribute_counts.csv"echo "ObjectTypeID,ObjectTypeName,UniqueCount" > "$OUTPUT_FILE"
# Fetch object schemasSCHEMAS=$(curl -s -X GET "$BASE_URL/objectschema/list" $AUTH_HEADER $CONTENT_HEADER)
# Validate if SCHEMAS is valid JSONif ! echo "$SCHEMAS" | jq empty 2>/dev/null; thenecho "Error: Invalid JSON response from object schemas API."exit 1fi
# Extract schema valuesSCHEMAS=$(echo "$SCHEMAS" | jq -c '.values[]')
# Loop through each schemaecho "$SCHEMAS" | while IFS= read -r SCHEMA; doSCHEMA_ID=$(echo "$SCHEMA" | jq -r '.id')# Fetch object types for this schemaOBJECT_TYPES=$(curl -s -X GET "$BASE_URL/objectschema/$SCHEMA_ID/objecttype/list" $AUTH_HEADER $CONTENT_HEADER)
# Validate if OBJECT_TYPES is valid JSONif ! echo "$OBJECT_TYPES" | jq empty 2>/dev/null; thenecho "Warning: Invalid JSON response for schema ID $SCHEMA_ID."continuefi
# Extract object typesOBJECT_TYPES=$(echo "$OBJECT_TYPES" | jq -c '.values[]')
echo "Processing schema ID: $SCHEMA_ID"# Loop through each object typeecho "$OBJECT_TYPES" | while IFS= read -r OBJ_TYPE; doOBJ_TYPE_ID=$(echo "$OBJ_TYPE" | jq -r '.id')OBJ_TYPE_NAME=$(echo "$OBJ_TYPE" | jq -r '.name')# Fetch attributes for this object typeATTRIBUTES=$(curl -s -X GET "$BASE_URL/objecttype/$OBJ_TYPE_ID/attributes" $AUTH_HEADER $CONTENT_HEADER)
# Validate if ATTRIBUTES is valid JSONif ! echo "$ATTRIBUTES" | jq empty 2>/dev/null; thenecho "Warning: Invalid JSON response for Object Type ID: $OBJ_TYPE_ID"UNIQUE_COUNT=0else# Extract attributes and check uniqueAttributeUNIQUE_COUNT=$(echo "$ATTRIBUTES" | jq '[.values[] | select(.uniqueAttribute == true)] | length')fi
echo "Object Type: $OBJ_TYPE_NAME (ID: $OBJ_TYPE_ID) - Unique Attributes: $UNIQUE_COUNT"
# Store resultsecho "$OBJ_TYPE_ID,$OBJ_TYPE_NAME,$UNIQUE_COUNT" >> "$OUTPUT_FILE"donedone
echo "Processing complete. Results saved to $OUTPUT_FILE."
Clean and simple way.
To Fetch workspace, use below request
https://<JSM Premium Site Name>.atlassian.net/rest/servicedeskapi/assets/workspace
Some people at my institute were quite confused when the email from Atlassian came up raising the issue. The program identified the unique constraints in question and the problem was quickly resolved.
https://github.com/pihodi/jsmAssetsNewLimitsCheck/blob/main/checkNewAssetsLimits.ps1Have fun
Hi @Prasad Bonthu
Can you share the postman workflow?
It looks like you're new here. Sign in or register to get started.