简体   繁体   English

提取Rally任务的所有者名称的正确方法是什么?

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

I'm using the RallyRestToolkitFor.NET and I'm pulling information from Rally tasks into our back office system. 我正在使用RallyRestToolkitFor.NET,并将信息从Rally任务中提取到我们的后台系统中。 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. 它非常适合Description和FormattedID,但在QueryResult中返回的所有者名称在Rally中实际设置时为空白。

I've tried "Owner", "User", "User.Name", and nothing has worked. 我尝试了“所有者”,“用户”,“ User.Name”,但没有任何效果。 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. 但是,我可以很好地查询Owner.Name ,但是无法在列表中获取它。 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"];

}

You can just fetch Owner and then also include individual fields from the User object type right in the same fetch: 您可以只提取Owner,然后在同一提取中直接包含User对象类型的各个字段:

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. WSAPI中的任何子对象子类型都应使用相同的概念。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM