Update existing work item (Epics, Features, User Stories, Tasks, Bugs, Test Plans, Test Plan Runs, Requests)

📘

Entity Types derived from Assignable base class

  • Epic
  • Feature
  • User Story
  • Task
  • Bug
  • Test Plan
  • Test Plan Run
  • Request
  • Inbound Assignable
  • Outbound Assignable

👍

More information

📘

To update a work item you have to know its ID.
If you'd like to connect a work item to some resources (EntityState, Team, Owner, Iteration, Release, etc.) you have to know their IDs.

Here are some popular queries:

  • change state for work item ID#194
    GET to /api/v1/assignables/194?include=[EntityState[NextStates]] (to know ID of the state)
    POST to /api/v1/assignables/194 payload {"EntityState":{"Id":82}}

  • add a new comment for work item ID#194
    POST to /api/v1/comments payload {"Description":"New comment","General":{"Id":194}}

  • add time spent for work item ID#194
    POST to /api/v1/times payload {"Spent":2,"Remain":1,"Description":"Some work","Role":{"Id":1},"Assignable":{"Id":194}}

  • estimate work item ID#194 (5 story points for Developer, 2 story points for QA)
    POST to /api/v1/assignables/194 payload {"Roleefforts":[{"Role":{"Id":1},"Effort":5},{"Role":{"Id":9},"Effort":2}]}

  • assign User ID#6 as Developer for work item ID#194
    POST to /api/v1/assignables/194 payload {"Assignments":[{"GeneralUser":{"Id":6},"Role":{"Id":1}}]}

  • set planned dates for work items (ID#194 and ID#195)
    POST to /api/v1/assignables/bulk payload [{"Id":194,"PlannedStartDate":"2017-03-19","PlannedEndDate":"2017-08-29"},{"Id":195,"PlannedStartDate":"2017-03-19","PlannedEndDate":"2017-08-29"}]

using System;
using System.Net;
using System.Net.Http;
using System.Text;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //set planned dates for work item ID#207
            string query = "assignables/207";
            string start = DateTime.Now.ToString("yyyy-MM-dd");
            string end = DateTime.Now.AddDays(14).ToString("yyyy-MM-dd");
            HttpContent payload = new StringContent("{\"PlannedStartDate\":\"" + start + "\",\"PlannedEndDate\":\"" + end + "\"}", Encoding.UTF8, "application/json");

            //using access token generated at Personal Details page (Access Tokens tab)
            query += "?access_token=NjplaXdQeTJDOHVITFBta0QyME85QlhEOWpwTGdPM2V6VjIyelZlZ0NKWG1RPQ==";
            Console.WriteLine("Posting to " + query);

            HttpResponseMessage response = client.PostAsync(query, payload).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //set planned dates for work item ID#207
            string query = "assignables/207";
            string start = DateTime.Now.ToString("yyyy-MM-dd");
            string end = DateTime.Now.AddDays(14).ToString("yyyy-MM-dd");
            HttpContent payload = new StringContent("{\"PlannedStartDate\":\"" + start + "\",\"PlannedEndDate\":\"" + end + "\"}", Encoding.UTF8, "application/json");

            //using a token generated at /api/v1/Authentication
            query += "?token=Njo4OTIyQzkzN0M5NEY3NzNENDIyNTM2RDU3MTMwMTMwOA==";
            Console.WriteLine("Posting to " + query);

            HttpResponseMessage response = client.PostAsync(query, payload).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //set planned dates for work item ID#207
            string query = "assignables/207";
            string start = DateTime.Now.ToString("yyyy-MM-dd");
            string end = DateTime.Now.AddDays(14).ToString("yyyy-MM-dd");
            HttpContent payload = new StringContent("{\"PlannedStartDate\":\"" + start + "\",\"PlannedEndDate\":\"" + end + "\"}", Encoding.UTF8, "application/json");

            //using basic authentication (here 'John' is login and '123' is password)
            string authentication = Convert.ToBase64String(Encoding.ASCII.GetBytes("John:123"));
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authentication);
            Console.WriteLine("Posting to " + query);

            HttpResponseMessage response = client.PostAsync(query, payload).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //set planned dates for work item ID#207
            string query = "assignables/207";
            string start = DateTime.Now.ToString("yyyy-MM-dd");
            string end = DateTime.Now.AddDays(14).ToString("yyyy-MM-dd");
            HttpContent payload = new StringContent("{\"PlannedStartDate\":\"" + start + "\",\"PlannedEndDate\":\"" + end + "\"}", Encoding.UTF8, "application/json");

            //using no authentication will result in 401 Unauthorized response
            Console.WriteLine("Posting to " + query);

            HttpResponseMessage response = client.PostAsync(query, payload).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}

📘

Updating several work itmes at once

You can operate with several work items at once by using /api/v1/assignables/bulk endpoint.

Language
Click Try It! to start a request and see the response here!