我为Rally中的缺陷配置了自定义weblink字段。我想使用Rally rest .net api相应地向Rally提交具有自定义weblink字段值的新缺陷。
不幸的是,weblink实例需要LinkID和DisplayString值,我不知道如何启动weblink实例来设置缺陷字段。
我也尝试设置一个Dynamic RsonObject,Rally支持.net api支持该字段,但它仍然失败。
调试截图
请帮忙!
编辑:
我尝试使用示例代码发布缺陷,如下所示:
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."],.....}
答案 0 :(得分:3)
这是相对简单的,您只需要为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);