How workspace scoping in the UI affects workspace scoping in WS API queries

Document ID : KB000047750
Last Modified Date : 14/02/2018
Show Technical Document Details

Summary

When a user has access to more than one workspace, scope queries to the intended workspace explicitly using "workspace" query parameter.

Issue

When a user has access to more than one workspace, some calls return unexpected results.
For instance, if the user has access to a? single workspace, the?/HierarchicalRequirement/789/Predecessors endpoint returns the expected list of user stories, but if this user is granted access to another workspace, it returns 0 results

Resolution

When a user has access to more than one workspace, the query result is scoped to the user's default workspace unless the workspace is explicitly set in the query using workspace parameter.

An example of explicit workspace parameter is shown here:
https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/789/Predecessors?workspace=/workspace/123

where 789 is ObjectID of a user story, and 123 is ObjectID of the workspace where this story is located.

If a user does not have default workspace set, but the user has access to more than one workspace, the first workspace returned by the query is used a "default" workspace, and is likely NOT to be the workspace to which the result is expected to belong.

The scenario below replicates the outcome described in the "Issue" section of this article, and shows how to scope the query properly:

1. Create a user with access to two workspaces. In this example? NMTest and NMSVN workspaces. The Default Workspace/Project is not set yet, as shown in the screenshot below:


User-added image

2. Set a default workspace/project:

User-added image

User-added image

3. In a non-default workspace of this user (NMSVN workspace) set a predecessor of a user story. In this example, US1, story1 is selected as a predecessor of US2 story2.
Make a note of ObjectID of "story2" (we will need it later).

User-added image

Here is a screenshot from Rally, showing the workspace picker with the current workspace NMSVN, which is a non-default workspace of the user.

User-added image

4. Log out of Rally. Open the Chrome's incognito window to make sure that cached credentials are not used.

5. Using the ObjectID of story2 from step 3 above, construct the predecessor endpoint:

https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/4942516478/Predecessors

where 4942516478 is the ObjectID of story 2.

You should be prompted to login:

User-added image



6. The endpoint returns 0 results. It is unexpected, since we know that this story (ObjectID:4942516478 ) has a predecessor. Here is the query result showing unexpected "TotalResultCount": 0:

{"QueryResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "TotalResultCount": 0, "StartIndex": 1, "PageSize": 20, "Results": []}}

7. In another tab of the same browser? (let's call it tab#2) login to Rally UI with this user's credentials, and switch form the default workspace NMTest to a non-default NMSVN workspace. The story in question is located in a non-default NMSVN workspace.

8. Refresh the page with the WS API result in another tab of the same browser (Let's call this tab#1). Now instead of TotalResultCount of 0, we see the full JSON of the predecessor of story 2. Only a fragment of it is shown:

"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/hierarchicalrequirement/4624500208", "_refObjectUUID": "f8ac23d1-df57-4507-971e-bf263f029138", "_objectVersion": "7", "_refObjectName": "story1", "CreationDate": "2011-10-28T17:24:49.389Z", ...."TestCase", "Count": 0}, "Feature": null, "PortfolioItem": null, "_type": "HierarchicalRequirement"}]}}

9. Go back to tab#2 and switch to default workspace NMTest:

User-added image.

10. Refresh tab#1 where the predecessor endpoint is tested. The result is 0 again:

{"QueryResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": [], "Warnings": [], "TotalResultCount": 0, "StartIndex": 1, "PageSize": 20, "Results": []}}

11. Use workspace query parameter to scope your query explicitly. The ObjectID of the non-default workspace of this user, NMSVN, where the story in question is located, is 4616847227.

https://rally1.rallydev.com/slm/webservice/v2.0/HierarchicalRequirement/4942516478/Predecessors?workspace=/workspace/4616847227

12. Notice that even though this user is logged in to Rally to a default workspace in the other tab of the same browser window, the query is no longer scoped to the default workspace:


User-added image
13. Here is the screenshot of the same query without the explicit workspace parameter:

User-added image

?