.net - 通过 Rally rest .net api 提交缺陷时如何设置自定义 WebLink 字段值?

标签 .net rest rally

我在 Rally 中为缺陷配置了一个自定义网络链接字段。我想使用 Rally rest .net api 相应地向 Rally 提交具有自定义 weblink 字段值的新缺陷。

不幸的是,weblink 实例需要 LinkID 和 DisplayString 值,我不知道如何启动 weblink 实例来设置缺陷字段。

我也曾尝试将 Rally rest .net api 支持的 DynamicJsonObject 设置到该字段,但它仍然失败。

调试截图 enter image description here

请帮忙!

已编辑:

我已经尝试使用如下示例代码发布缺陷:

        var api = new RallyRestApi("<myusername>", "<mypassword>", "https://community.rallydev.com");

        var defect = new DynamicJsonObject();
        defect["Name"] = "Sample Defect";
        defect["Description"] = "Test posting defect with weblink type field";
        defect["Project"] = "https://trial.rallydev.com/slm/webservice/1.29/project/5839639589.js";
        defect["SubmittedBy"] = "https://trial.rallydev.com/slm/webservice/1.29/user/5797741589.js";
        defect["ScheduleState"] = "In-Progress";
        defect["State"] = "Open";
        defect["Severity"] = "Major Problem";
        defect["Priority"] = "High Attention";
        defect["CustWebLink"] = new DynamicJsonObject(new Dictionary<string, object> 
        {
            {"DisplayString", "abc"},
            {"LinkID", "123"}
        });

        CreateResult creationResult = api.Create("defect", defect);

现在可以将缺陷发布到 Rally,但没有 CustWebLink 的值(value)。在调查过程中,我发现 CustWebLink 字段在发布请求的序列化中被忽略了。

  Rally.RestApi Post Response: {"CreateResult": {"_rallyAPIMajor": "1", "_rallyAPIMinor": "29", "Errors": [], "Warnings": ["Ignored JSON element defect.CustWebLink during processing of this request."],.....}

最佳答案

这相对简单,您只需为 Weblink 创建单独的 DynamicJsonObject,并为其 LinkID 和 DisplayString 属性赋值。然后,将 Weblink 对象指定为缺陷的字段。这是一个简单的例子:

    //Set our Workspace and Project scopings

    String workspaceRef = "/workspace/5912034914";
    String projectRef = "/project/5912035004";

    DynamicJsonObject myDefect = new DynamicJsonObject();
    DynamicJsonObject myWeblink = new DynamicJsonObject();

    // Populate the Weblink
    myWeblink["LinkID"] = "123456";
    myWeblink["DisplayString"] = "External Image Link";

    // Populate the Defect
    myDefect["Name"] = "My Defect";
    myDefect["Priority"] = "Normal";
    myDefect["Workspace"] = workspaceRef;
    myDefect["Project"] = projectRef;
    myDefect["zWeblinkField"] = myWeblink;

    CreateResult createDefect = restApi.Create("Defect", myDefect);

关于.net - 通过 Rally rest .net api 提交缺陷时如何设置自定义 WebLink 字段值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9922365/

相关文章:

java - 运行 Jersey Rest API 而不使用容器作为 jar

java - jboss Resteasy参数注入(inject)@Context

javascript - 数据源查询回调问题(调用顺序、改变全局变量的能力)

c# - 程序集在运行时解析

c# - 您会相信 Mono 作为建立初创公司的平台吗?

c# - 互操作:结构成员名称与 c# 关键字冲突 - 事件

java - Spring 文件上传 - 'Required request part is not present'

java - Rally java Rest API - 处理此请求期间忽略 JSON 元素

java - Rally API,创建测试用例结果 - 连接关闭异常

.net - .Net 项目中的拼写检查消息字符串