I'm trying to automate build artifact download. The objective is to download a specific build artifact. When I call BuildClient.GetArtifactContentZipAsync, it throws the following error
I am using the following code
private static void DownloadBuildResults(Build StartedBuild, string ArtifactName)
{
//BuildArtifact drop = BuildClient.GetArtifactAsync(StartedBuild.Id, ArtifactName).Result; //get detiled info
//Console.WriteLine("Build location: " + drop.Resource.DownloadUrl);
//string dropFileName = String.Format("{0}_{1}.zip", StartedBuild.Definition.Name, StartedBuild.BuildNumber);
Stream zipStream = BuildClient.GetArtifactContentZipAsync(79414, "abc").Result; //get content
using (FileStream zipFile = new FileStream("abc.zip", FileMode.Create))
zipStream.CopyTo(zipFile);
Please note that I buildID and artifact name is correct. I have double-checked these values. The above code example is taken from https://github.com/ashamrai/TFRestApi/blob/master/19.TFRestApiAppQueueBuild/TFRestApiApp/Program.cs
Is this a bug in the API/SDK? or Am I doing something wrong?
Here is the sample code if someone wants to give a try GIST: https://gist.github.com/abhishekgoenka/9759256f995e7f7c9cbcb7872c8591c0
Stack trace
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__53.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.TeamFoundation.Build.WebApi.BuildHttpClientBase.<GetArtifactContentZipAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Utils.Dashboard.FrmAzureDashboard.<BtnDownloadKHP_Click>d__13.MoveNext() in C:\code\MetaFXTools\ui\Utils\Dashboard\FrmAzureDashboard.cs:line 118




