Click here to Skip to main content
13,904,565 members
Click here to Skip to main content
Add your own
alternative version


Posted 6 Jul 2016
Licenced CPOL

Visual Studio Team Foundation Service Agile Bugs P2

, 6 Jul 2016
Rate this:
Please Sign up or sign in to vote.
Visual Studio Team Foundation Service Agile Bugs P2


This is a second part to my first article. This part will show how to create different types of workitems. Move the Item from the main project list to Iterations or child Iterations.

Work Type Types

With Visual Studio Team Foundation Services, you have the default types of Bugs, Task and User Stories. If you want to use the API to create any of these types, you simply alter the URL as so.

string NewWorkItem = 
   url = url.Replace("[ACCOUNT]", account);
   url = url.Replace("[PROJECT]", project);

//Alter to create a user story
   url = url.Replace("[WORKTYPE]", "User Story");
//Alter to create a Task
   url = url.Replace("[WORKTYPE]", "Task");
//Alter to create a BUG
   url = url.Replace("[WORKTYPE]", "Bug");

If you create your own, custom types (not 100% sure), but the documents do state that you can. All you need to do is alter the code to include your type.

Move Iterations or Child Iterations

Once you have created the work Item, use the below code to move the items from the root to your new area. This needs a patch call and the below URL and JSON package.

       public static void Add(int workItemId, string areaPath, string iterationPath)
            iteration = iterationPath;
            area = areaPath;
            string UpdateWorkItem = 

            string url = String.Format(UpdateWorkItem, workItemId.ToString());
            wiPostDataArr = new List<DataObjectsProject.VSOJasonWorkItemPostData>();


            Models.Helpers.JASONHelper.Patch(url, httpStringContent, 
            new Models.Helpers.JASONHelper.JSONReturnCallBack(historyLinkReturn));

        private static void createInitailItemPostObject()
                AddUpdateProp("/fields/System.AreaPath", area);
            if (!String.IsNullOrEmpty(iteration))
                AddUpdateProp("/fields/System.IterationPath", iteration); 

            httpStringContent = ConvertDataClassToJason(wiPostDataArr);

        private static void AddUpdateProp(string field, object value)
            DataObjectsProject.VSOJasonWorkItemPostData wiPostData = 
            new DataObjectsProject.VSOJasonWorkItemPostData();
            wiPostData.op = "add";
            wiPostData.path = field;
            wiPostData.value = value;

//The class object to create the Json package
   public class VSOJasonWorkItemPostData
        public string op;
        public string path;
        public object value;

You can have a look at the application in more detail:

  1. Published version from the online site
  2. See the code within the downloadable
  3. Look at the code within the GitHub repo


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Thomas Cooper
United Kingdom United Kingdom
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190306.1 | Last Updated 6 Jul 2016
Article Copyright 2016 by Thomas Cooper
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid