我试图通过以下代码通过Rest .net api向Rally发布新的缺陷:
var api = new RallyRestApi("<myusername>", "<mypassword>", "https://community.rallydev.com");
var defect = new DynamicJsonObject();
defect["Name"] = "Sample Defect";
defect["Description"] = "Test posting defect without required field value";
defect["Project"] = "https://trial.rallydev.com/slm/webservice/1.29/project/5808130051.js";
defect["SubmittedBy"] = "https://trial.rallydev.com/slm/webservice/1.29/user/5797741589.js";
defect["ScheduleState"] = "In-Progress";
defect["State"] = "Open";
CreateResult creationResult = api.Create("defect", defect);
但api引发了一个奇怪的例外:
System.Collections.Generic.KeyNotFoundException was unhandled
Message=The given key was not present in the dictionary.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Rally.RestApi.DynamicJsonObject.GetMember(String name)
at Rally.RestApi.DynamicJsonObject.TryGetMember(GetMemberBinder binder, Object& result)
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at Rally.RestApi.RallyRestApi.Create(String type, DynamicJsonObject obj)
at RallyIntegrationSample.Program.Main(String[] args) in D:\Projects\qTrace\References\Samples\RallyIntegrationSample\Program.cs:line 24
问题是当我检出Rally的跟踪日志文件时,它显示了发布请求中的错误:
Rally.RestApi Post Response:
{
"CreateResult":
{
"_rallyAPIMajor":"1",
"_rallyAPIMinor":"29",
"Errors":["Validation error: Defect.Severity should not be null"],
"Warnings":[]
}
}
Rally Rest .Net Api不会在其属性中给出具有相应错误信息的正确CreateResult对象,而是抛出意外异常。
这是Rally中的错误.net api还是我应该做任何额外的步骤来无缝地获取CreatResult以防Rally服务返回任何错误?
非常感谢你的帮助。
答案 0 :(得分:2)
这听起来像是一个缺陷。在接下来的一周左右将有一个维护版本的库来修复另一个缺陷 - 我会尝试重复这个并发布我的发现。