What is the proper way to fetch the Owner Name of a Rally Task?

笑着哭i 提交于 2019-12-24 14:28:32

问题


I'm using the RallyRestToolkitFor.NET and I'm pulling information from Rally tasks into our back office system. It is all working well except I'm having trouble fetching the name of the "Owner" of the task.

In fact, I can't seem to pull any information from the Owner. Below is a code snippet so you can see what I'm doing. It works great for the Description and FormattedID but the Owner name returned in the QueryResult is blank when it's actually set in Rally.

I've tried "Owner", "User", "User.Name", and nothing has worked. I guess I'm just stumped on how to retrieve the Owner Name on a task. However, I can query on Owner.Name just fine, but I'm not able to fetch it in the list. Does anyone have any ideas?

Request request = new Request("task");

request.Fetch = new List<string>() {"Owner.Name", "Description", "FormattedID" };

request.Query = new Query("Project.Name", Query.Operator.Equals, "My Project"); 

QueryResult queryResult = restApi.Query(request);

foreach (var result in queryResult.Results)

{

ownerName = result["Owner.Name"];

}

回答1:


You can just fetch Owner and then also include individual fields from the User object type right in the same fetch:

request.Fetch = new List<string>() {"Owner", "UserName", "DisplayName" };

and then in the response:

owner = result["Owner"]
if(owner != null) 
{
    ownerName = owner["UserName"]
}

This same concept should work for any child object sub types in WSAPI.



来源:https://stackoverflow.com/questions/32621290/what-is-the-proper-way-to-fetch-the-owner-name-of-a-rally-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!