enter image description here任何人都可以告诉我如何在VSO上以块的形式上传文件
https://www.visualstudio.com/en-us/docs/integrate/api/wit/attachments#chunked-upload [下面是我已经使用的代码,但我在UpdateWorkItemAsync方法中遇到异常......异常 - :{“TF237136:文件附件不存在,或者您没有权限读取它。”}
答案 0 :(得分:1)
var u = new Uri("https://v-vabhan.visualstudio.com/");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, pad));
var connection = new VssConnection(u, c);
var workItemTracking = connection.GetClient<WorkItemTrackingHttpClient>();var attachment = workItemTracking.CreateAttachmentAsync("D:\\Area.xml","chunked").Result;
JsonPatchDocument patchDocument = new JsonPatchDocument();
patchDocument.Add(new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations/-",
Value = new
{
rel = "AttachedFile",
url = attachment.Url,
attributes = new
{
comment = "VanDelay Industries - Spec"
}
}
});
WorkItem result = workItemTracking.UpdateWorkItemAsync(patchDocument, id).Result;
Console.WriteLine("Done attachment.........."+result.Url);
答案 1 :(得分:0)
试试这段代码:
代码:
var u = new Uri("https://xxx.visualstudio.com");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[PAT]"));
var connection = new VssConnection(u, c);
var workItemTracking = connection.GetClient<WorkItemTrackingHttpClient>();
var attachement= workItemTracking.CreateAttachmentAsync("D:\\WebAPITest2.zip", "chunked").Result;