1
我試圖在兩個工作區中同時創建一個TAG。拉力賽:創建標籤失敗
我遍歷我們的訂閱工作區並查詢標籤以查看標籤是否已經存在。
如果標籤不存在,我創建它。
但它只在我們以後的工作區創建TAG,並且從不在較老的區域創建TAG。
任何想法我可能做錯了什麼?
static void Main(string[] args)
{
string id = "TEST";
RallyRestApi restApi = new RallyRestApi("[email protected]", "mypassword", "https://rally1.rallydev.com", "v2.0");
DynamicJsonObject sub = restApi.GetSubscription("Workspaces");
Request wRequest = new Request(sub["Workspaces"]);
Rally.RestApi.Response.QueryResult queryResult = restApi.Query(wRequest);
foreach (var result in queryResult.Results)
{
var workspaceReference = result["_ref"];
Request tagRequest = new Request("tag")
{
Workspace = workspaceReference,
Fetch = new List<string>() { "Name", "ObjectID" },
Query = new Query("Name", Query.Operator.Equals, id)
};
QueryResult tagResult = restApi.Query(tagRequest);
if (tagResult.TotalResultCount == 0)
{
DynamicJsonObject newTag = new DynamicJsonObject();
newTag["Name"] = id;
CreateResult createResult = restApi.Create(workspaceReference, "Tag", newTag);
Console.Out.WriteLine("TAG " + id + " not found, creating");
Console.Out.WriteLine(createResult.Reference);
}
else
{
Console.Out.WriteLine("TAG " + id + " found");
Console.Out.WriteLine(tagResult.Results.First()["_ref"]);
}
}
Console.ReadKey();
}
當我運行此,我總是得到下面的結果提前
TAG TEST not found, creating
https://rally1.rallydev.com/slm/webservice/v2.0/tag/19735777148
TAG TEST found
https://rally1.rallydev.com/slm/webservice/v2.0/tag/19735777148
感謝這個