0

这是我要更新的字段的屏幕截图:

在此处输入图像描述

如何更新 URL 字段?

4

1 回答 1

0

WebLink 类型字段由两部分组成:LinkID 和 DisplayString。为了设置 LinkID(对应于屏幕截图中的变量 ${id},还需要将 DisplayString 设置为空字符串。

以下是使用 Rally .NET REST 工具包的完整代码示例:

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/1111"; //please replace this OID with an OID of your workspace 
            String projectRef = "/project/2222";     //please replace this OID with an OID of your project
            bool projectScopingUp = false;
            bool projectScopingDown = true;

            Request storyRequest = new Request("Defect");


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

            storyRequest.Fetch = new List<string>()
                {
                    "Name",
                    "_ref",
                    "c_JiraLink"
                };

            storyRequest.Query = new Query("FormattedID", Query.Operator.Equals, "DE170");       
            QueryResult queryStoryResults = restApi.Query(storyRequest);

            foreach (var s in queryStoryResults.Results)
            {
               Console.WriteLine(" Name: " + s["Name"] + " JiraLink's DisplayString: " + s["c_JiraLink"]["DisplayString"] + " JiraLink's LinkID: " + s["c_JiraLink"]["LinkID"]);  
               DynamicJsonObject toUpdate = new DynamicJsonObject();
               DynamicJsonObject myLink = new DynamicJsonObject();
               myLink["LinkID"] = "NM-3";
               myLink["DisplayString"] = "";
               toUpdate["c_JiraLink"] = myLink;

               OperationResult updateResult = restApi.Update(s["_ref"], toUpdate);  
            }
        }
    }
}

请注意,这与使用浏览器的 REST 客户端设置 WebLink 类型的文件的 LinkID 的更一般示例没有什么不同。

方法:POST

网址:

https://rally1.rallydev.com/slm/webservice/v2.0/defect/3807704995?key=abc123...

请求正文:

{
"defect":
{
"c_JiraLink":{
"DisplayString":"",
"LinkID":"NM-2"
}
}
}
于 2013-08-26T17:59:00.630 回答