WSAPI / API - Get AllowedValues for Rally dropdown fields
search cancel

WSAPI / API - Get AllowedValues for Rally dropdown fields

book

Article ID: 57584

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

If a user is logged in to the Rally UI in a non-default workspace, and hits AllowedValues endpoint in another tab of the same browser window, and later switches from a non-default workspace to a default workspace in the UI, reloading the page with AllowedValues query returns results no longer scoped to the original non-default workspace.

Resolution

NOTE: When following this example use unique ObjectIDs specific to your subscription.

We start with a typedefinition endpoint for artifacts of type Defect.
The goal is to eventually traverse from typedefinition to attirbutes to allowedvalues.
Currently we are logged in to Rally to a default workspace. In another tab of the same browser window paste this URL;
 
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition?query=(Name = Defect)

This json is returned:
 
{
QueryResult: {
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
Errors: [ ],
Warnings: [ ],
TotalResultCount: 1,
StartIndex: 1,
PageSize: 20,
Results: [
{
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/<OBJECT_ID>",
_refObjectUUID: "<OBJECT_UUID>",
_refObjectName: "Defect",
_type: "TypeDefinition"
}
]
}
}
 
We are interested in the /typedefinition/<OBJECT_ID> endpoint. Paste the full URL in another tab of the same browser:
 
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/<OBJECT_ID>
 
Locate attirbutes:
 
Attributes: {
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/TypeDefinition/<OBJECT_ID>/Attributes",
_type: "AttributeDefinition",
Count: 71
},
 
Paste attributes endpoint in the browser:
 
https://rally1.rallydev.com/slm/webservice/v2.0/TypeDefinition/<OBJECT_ID>/Attributes
 
Search the results (Ctrl+F) for an attribute name, e.g. State.
You will notice that even though ScheduleState is found, but State is not. The default page size in WS API is 20. Max page size is 200. Set the pagesize to 200 as shown below./div>
https://rally1.rallydev.com/slm/webservice/v2.0/TypeDefinition/<OBJECT_ID>/Attributes?pagesize=200
 
Now Ctrl+F on "State" should return more matches on the single page. Locate "State"
  • {
    • _rallyAPIMajor:"2",
    • _rallyAPIMinor:"0",
    • _ref:"https://rally1.rallydev.com/slm/webservice/v2.0/attributedefinition/<OBJECT_ID>",
    • _refObjectUUID:"<OBJECT_UUID>",
    • _objectVersion:"1",
    • _refObjectName:"State",
    • CreationDate:"2006-02-11T12:29:05.000Z",
    • _CreatedAt:"Feb 11, 2006",
    • ObjectID:<OBJECT_ID>,
    • VersionId:"1",
    • Subscription:{},
    • Workspace:null,
    • AllowedQueryOperators:{},
    • AllowedValueType:null,
    • AllowedValues:{
      • _rallyAPIMajor:"2",
      • _rallyAPIMinor:"0",
      • _ref:"https://rally1.rallydev.com/slm/webservice/v2.0/AttributeDefinition/<OBJECT_ID>/AllowedValues",
      • _type:"AllowedAttributeValue",
      • Count:4
      },
    • AttributeType:"RATING",
    • Constrained:true,
    • Custom:false,
    • ElementName:"State",
    • Filterable:true,
    • Hidden:false,
    • MaxFractionalDigits:span style="color: blue;">-1,
    • MaxLength:span style="color: blue;">128,
    • Name:span style="color: green;">"State",
    • Note:span style="color: green;">"State of the defect",
    • Owned:span style="color: rgb(178, 34, 34);">true,
    • ReadOnly:span style="color: rgb(178, 34, 34);">false,
    • Required:span style="color: rgb(178, 34, 34);">true,
    • Sortable:span style="color: rgb(178, 34, 34);">true,
    • SystemRequired:span style="color: rgb(178, 34, 34);">true,
    • Type:span style="color: green;">"string",
    • VisibleOnlyToAdmins:span style="color: rgb(178, 34, 34);">false,
    • _type:span style="color: green;">"AttributeDefinition"
    },
 
Paste this endpoint in the browser to get to the allowed values:
https://rally1.rallydev.com/slm/webservice/v2.0/AttributeDefinition/<OBJECT_ID>/AllowedValues
The four State values: Submitted, Open, Fixed, and Closed are returned:

{
  • QueryResult:{
    • _rallyAPIMajor:span style="color: green;">"2",
    • _rallyAPIMinor:span style="color: green;">"0",
    • Errors: [ ],
    • Warnings: [ ],
    • TotalResultCount:span style="color: blue;">4,
    • StartIndex:span style="color: blue;">0,
    • PageSize:span style="color: blue;">0,
    • Results:[
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:17 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Submitted",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:17 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Open",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:17 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Fixed",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:17 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Closed",
        • _type:span style="color: green;">"AllowedAttributeValue"
        }
      ]
    }
}
 

 
Let's consider scoping. Go back to the typedefinition endpoint and this time explicilty fetch workspace:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition?query=(Name = Defect)&fetch=workspace
Locate Workspace object in the return. Notice that the result is referencing the default workspace of the current user:
/div>
https://rally1.rallydev.com/slm/webservice/v2.0/workspace/<WORKSPACE_OID>
Let's switch to a another workspace in the Rally UI. To illustrate the difference we choose a workspace where State values have been customized:


 
To scope typedefinition request to a different workspace use the query with workspace parameter:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/<WORKSPACE_OID>&query=(Name = Defect)
Here is the result:
{
QueryResult: {
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
Errors: [ ],
Warnings: [ ],
TotalResultCount: 1,
StartIndex: 1,
PageSize: 20,
Results: [
{
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/<OBJECT_OID>",
_refObjectUUID: "<OBJECT_UUID>",
_refObjectName: "Defect",
_type: "TypeDefinition"
}
]
}
}
Notice that the ObjectID of the typedefinition <OBJECT_OID> in a non-default workspace is different from the ObjectID of the typedefinition in default workspace <WORKSPACE_OID>:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/<OBJECT_OID> - A non-default workspace
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/<OBJECT_OID> - The default workspace of the current user
 
Let's trace the span style="font-family: courier new,courier,monospace;">/typedefinition/<OBJECT_OID> to State's AllowedValues in a non-default workspace. We want to verify that those are different from the AllowedValues in the default workspace.
Paste this in another tab of the same browser:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/<OBJECT_OID>
Locate the Attributes object in the results:
 
  • Attributes:{
    • _rallyAPIMajor:span style="color: green;">"2",
    • _rallyAPIMinor:span style="color: green;">"0",
    • _ref:span style="color: green;">"https://rally1.rallydev.com/slm/webservice/v2.0/TypeDefinition/<OBJECT_OID>/Attributes",
    • _type:span style="color: green;">"AttributeDefinition",
    • Count:span style="color: blue;">71
    },

Ctrl+F the results to locate AllowedValues for "State":
 
  • AllowedValues:{
    • _rallyAPIMajor:span style="color: green;">"2",
    • _rallyAPIMinor:span style="color: green;">"0",
    • _ref:span style="color: green;">"https://rally1.rallydev.com/slm/webservice/v2.0/AttributeDefinition/<OBJECT_OID>/AllowedValues",
    • _type:span style="color: green;">"AllowedAttributeValue",
    • Count:span style="color: blue;">6
    },

The AllowedValues now return 6 values (different from 4 values in the default workspace) as expected:

{
  • QueryResult:{
    • _rallyAPIMajor:span style="color: green;">"2",
    • _rallyAPIMinor:span style="color: green;">"0",
    • Errors: [ ],
    • Warnings: [ ],
    • TotalResultCount:span style="color: blue;">6,
    • StartIndex:span style="color: blue;">0,
    • PageSize:span style="color: blue;">0,
    • Results:[
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:52 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Submitted",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:52 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Open",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:52 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Fixed",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:52 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Closed",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:52 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Reopen",
        • _type:span style="color: green;">"AllowedAttributeValue"
        },
      • {
        • _rallyAPIMajor:span style="color: green;">"2",
        • _rallyAPIMinor:span style="color: green;">"0",
        • _ref:span style="color: green;">"null",
        • _refObjectUUID:span style="color: green;">"",
        • _objectVersion:span style="color: green;">"0",
        • CreationDate:span style="color: gray;">null,
        • _CreatedAt:span style="color: green;">"today at 10:52 am",
        • ObjectID:span style="color: gray;">null,
        • VersionId:span style="color: green;">"0",
        • StringValue:span style="color: green;">"Rejected",
        • _type:span style="color: green;">"AllowedAttributeValue"
        }
      ]
    }
}
 

 
Even though the AllowedValues are different in the non-default workspace, notice that the URL is not unique across the workspaces.
We used the same/font>
https://rally1.rallydev.com/slm/webservice/v2.0/AttributeDefinition/<OBJECT_OID>/AllowedValues
How does Rally know how to scope if in both cases "-12507" is used? We are currently logged in to Rally in another tab of the same browser, in the non-default /workspace/1448050317
If a user switches the workspace to a default workspace where the user is logged in to Rally's UI and reloads the other page with the WS API request:
/div>
https://rally1.rallydev.com/slm/webservice/v2.0/AttributeDefinition/<OBJECT_OID>/AllowedValues
/div>
now the AllowedValues reflect 4 values from the default workspace. This may be unexpected since we traversed from a typedefinition request that was explicitly scoped to a non-default workspace.
To scope the AllowedValues request to the desired workspace regardless of what workspace the user is currently logged in in the Rally UI in another tab of the same browser window explicitly scope the request using workspace parameter:
/div>
https://rally1.rallydev.com/slm/webservice/v2.0/AttributeDefinition/<OBJECT_OID>/AllowedValues?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/<WORKSPACE_OID>
/div>
Now 6 values from a non-default workspace are returned as expected, even though we are logged in a default workspace in Rally UI in another tab of the same browser.