gpt4 book ai didi

c# - RallyDev - 使用 Rally.RestAPI.dll 和 Service V2.0 获取故事任务

转载 作者:行者123 更新时间:2023-11-30 17:52:20 34 4
gpt4 key购买 nike

我正在从位于 https://rally1.rallydev.com 的 Rally 服务器中提取数据使用 C# 和 Rally.RestAPI.dll。服务器最近升级到 webservice v2.0,我在获取用户故事任务时遇到了一些问题。我知道随着迁移到 2.0,API 中子集合的呈现方式发生了变化,但我正在尝试的方法不起作用。

最佳答案

v2.0 删除了返回子集合的能力出于性能原因的响应。现在获取一个集合将返回具有计数和从中获取集合的 url 的对象data.A separate request is needed to get to the elements 的元素收藏。以下是迭代用户故事结果、访问故事上的“任务”集合并发出单独请求以访问各个任务属性的代码:

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Rally.RestApi;
using Rally.RestApi.Response;

namespace aRestApp_CollectionOfTasks
{
class Program
{
static void Main(string[] args)
{
//Initialize the REST API
RallyRestApi restApi;
restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");

//Set our Workspace and Project scopings
String workspaceRef = "/workspace/11111"; //please replace this OID with an OID of your workspace
String projectRef = "/project/22222"; //please replace this OID with an OID of your project
bool projectScopingUp = false;
bool projectScopingDown = true;

Request storyRequest = new Request("HierarchicalRequirement");


storyRequest.Workspace = workspaceRef;
storyRequest.Project = projectRef;
storyRequest.ProjectScopeUp = projectScopingUp;
storyRequest.ProjectScopeDown = projectScopingDown;

storyRequest.Fetch = new List<string>()
{
"Name",
"FormattedID",
"Tasks",
"Estimate"


};
storyRequest.Query = new Query("LastUpdateDate", Query.Operator.GreaterThan, "2013-08-01");
QueryResult queryStoryResults = restApi.Query(storyRequest);

foreach (var s in queryStoryResults.Results)
{
Console.WriteLine("----------");
Console.WriteLine("FormattedID: " + s["FormattedID"] + " Name: " + s["Name"]);
//Console.WriteLine("Tasks ref: " + s["Tasks"]._ref);
Request taskRequest = new Request(s["Tasks"]);
QueryResult queryTaskResult = restApi.Query(taskRequest);
if (queryTaskResult.TotalResultCount > 0)
{
foreach (var t in queryTaskResult.Results)
{
var taskEstimate = t["Estimate"];
var taskName = t["Name"];
Console.WriteLine("Task Name: " + taskName + " Estimate: " + taskEstimate);
}
}
else
{
Console.WriteLine("no tasks found");
}
}
}
}
}

关于c# - RallyDev - 使用 Rally.RestAPI.dll 和 Service V2.0 获取故事任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18411679/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com