Question

I have been working on a small winform c# App that will enable me to create a work item in TFS without having to actually go on the TFS server. I have figured out how to add the title, attachments, description etc. However I cant seem to figure out how to insert a local image into the TFS work Item "Repro Steps" field. Here is my code so far.

Uri collectionUri = new Uri("Server Adress" + project);
TfsTeamProjectCollection server = new TfsTeamProjectCollection(collectionUri);
WorkItemStore store = (WorkItemStore)server.GetService(typeof(WorkItemStore));

WorkItem workItem = store.Projects[SubProject].WorkItemTypes["Bug"].NewWorkItem();
workItem.Title = "Title";
workItem.IterationPath = "Iteration";
workItem.AreaPath = "Area"; 

workItem.Fields["repro steps"].Value = "Text"; //Here is where I would like to add my image

workItem.Fields["Assigned To"].Value = "Assigned";
workItem.Attachments.Add(new Attachment(File, "comment"));
workItem.Save();

For further clarification here is what I am essentially trying to do: enter image description here

enter image description here

enter image description here

Was it helpful?

Solution

I believe that the Description field is encoded as a variety of HTML and the image is first attached as a separate file. (Historically it was a text field so I cannot find anything saying otherwise)

Here is an example of attaching a file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top