我已经为Rally中的缺陷配置了一个自定义的Weblink字段。而且我想使用Rally rest .net api来根据Rally提交具有自定义Weblink字段值的新缺陷。

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

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

调试截图

请帮忙!

编辑:

我尝试用以下示例代码发布缺陷:

        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的价值。在调查时,我看到在发布请求的序列化过程中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);

09-03 17:55