public void AddAttachment() { // Create a file to attach with sample text var filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); using (FileStream fstream = File.Create(filePath)) { using (StreamWriter swriter = new StreamWriter(fstream)) { swriter.Write("Sample attachment text"); } } // Upload attachment AttachmentReference attachment = WitClient.CreateAttachmentAsync(filePath).Result; Console.WriteLine("Attachment created"); Console.WriteLine($"ID: {attachment.Id}"); Console.WriteLine($"URL: '{attachment.Url}'"); Console.WriteLine(); // Get an existing work item and add the attachment to it WorkItem wi = WitClient.GetWorkItemAsync(this.WorkItemsAdded.First()).Result; JsonPatchDocument attachmentPatchDocument = new JsonPatchDocument { new JsonPatchOperation() { Operation = Operation.Add, Path = "/relations/-", Value = new { rel = "AttachedFile", url = attachment.Url, attributes = new { comment = "Attached a file" } } } }; var attachments = wi.Relations?.Where(r => r.Rel == "AttachedFile") ?? new List <WorkItemRelation>(); var previousAttachmentsCount = attachments.Count(); var result = WitClient.UpdateWorkItemAsync(attachmentPatchDocument, wi.Id.Value).Result; var newAttachments = result.Relations?.Where(r => r.Rel == "AttachedFile"); var newAttachmentsCount = newAttachments.Count(); Console.WriteLine($"Updated Existing Work Item: '{wi.Id}'. Had {previousAttachmentsCount} attachments, now has {newAttachmentsCount}"); Console.WriteLine(); }