我在尝试上传附件时随机出现此错误。 “Rally API“无法从传输连接读取数据:连接已关闭。”
”无法从传输连接读取数据:连接是 已关闭。“
我有一个使用C#RallyRestAPI的导入函数,该函数从测试轨道中提取数据并将其插入到拉力赛中,并将其复制到拉力赛的附件中。我的测试数据有3个附件,大小各不相同,分别为350k,63k和43k。当我运行我的导入程序时,它会在不同的时间出现不同的上传错误。它没有一致性。有时候所有三个都会失败,有时候第二个和第三个都会成功。创建和更新故事看起来没问题,所以看起来像是超时,但我不确定如何更改RallyRestAPI中的超时。
有没有其他人遇到过这个问题使用C#和拉力赛RestAPI?
这是我的上传代码。对Connect()的调用返回一个RallyRestAPI对象并登录到该对象中。我每次打电话给拉力赛都会重新登录(不确定是否需要这样做)。
private string AddAttachment(string reference, string name, string content, long contentSize, string type) {
var restAPI = Connect();
try {
var attachmentContent = new DynamicJsonObject();
attachmentContent["Content"] = content;
attachmentContent["Workspace"] = _workspace["_ref"];
attachmentContent["Project"] = _target["_ref"];
var result = restAPI.Create("AttachmentContent", attachmentContent);
if (result.Success) {
_logger.Info("Attached the relevant AttachmentContent.");
}
else {
throw new LoggedException("Could not attach attachment to '" + reference + "' due to the following errors\n" + GetErrorList(result.Errors));
}
var attachmentContentRef = result.Reference;
// DynamicJSONObject for Attachment Container
var myAttachment = new DynamicJsonObject();
myAttachment["Workspace"] = _workspace["_ref"];
myAttachment["Project"] = _target["_ref"];
myAttachment["Artifact"] = reference;
myAttachment["Content"] = attachmentContentRef;
myAttachment["Name"] = Path.GetFileName(name);
var contentType = "image/jpg";
if (!string.IsNullOrEmpty(type)) {
switch (type.Trim().ToLower()) {
case "doc":
contentType = "document/text";
break;
default:
contentType = type;
break;
}
}
myAttachment["ContentType"] = contentType;
myAttachment["Size"] = contentSize;
result = restAPI.Create("Attachment", myAttachment);
if (result.Success) {
_logger.Info("Attached the relevant attachment.");
}
else {
throw new LoggedException("Could not attach attachment to '" + reference + "' due to the following errors\n" + GetErrorList(result.Errors));
}
return attachmentContentRef;
}
catch (Exception ex) {
throw new LoggedException("Unhandled exception occurred: ",ex);
}
}
感谢您的详细信息。几个问题 - 你使用代理吗?你的代码使用什么版本的Rally Webservices? – 2013-02-20 15:06:42
不,我没有使用代理服务器,我没有在我的连接中指定特定的API版本,让它使用当前版本,我相信它是1.37。 正在上传的数据的“content”参数是使用'Convert.ToBase64String(fs)'的Base64String。 – trevleyb 2013-02-20 21:19:58