Update existing or create a new User Story

👍

More information

📘

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

Here are some popular queries:

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

  • set value "Tech debt" for custom field "Work Type" for a Story ID#194
    POST TO /api/v1/userstories/194 payload {"CustomFields":[{"Name":"Work Type","Value":"Tech debt"}]}

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

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

  • create a Task for a Story ID#194
    GET to /api/v1/userstories/194?include=[Project] (to know ID of the project)
    POST to /api/v1/tasks payload {"Name":"New task","Project":{"Id":2},"UserStory":{"Id":194}}

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

  • add a Story to a Project ID#2 and assign User ID#6 as Developer
    POST to /api/v1/userstories payload {"Name":"New story","Project":{"Id":2},"Assignments":[{"GeneralUser":{"Id":6},"Role":{"Id":1}}]}

  • add a Story to a Project ID#2, assign User ID#6 as Developer and estimate development work with 10 story points
    POST to /api/v1/userstories payload {"Name":"New story","Project":{"Id":2},"Assignments":[{"GeneralUser":{"Id":6},"Role":{"Id":1}}],"Roleefforts":[{"Role":{"Id":1},"Effort":10}]}

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

  • create several Stories for a Feature ID#206
    GET to /api/v1/features/206?include=[Project] (to know ID of the project)
    POST to /api/v1/UserStories/bulk payload [{"Project":{"Id":192},"Name":"First Story","Feature":{"Id":206}},{"Project":{"Id":192},"Name":"Second Story","Feature":{"Id":206}}]

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;

            //create a new User Stories in a Project ID#2
            string query = "userstories";
            HttpContent payload = new StringContent("{\"Name\":\"New Story\",\"Project\":{\"Id\":2}}", 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;

            //create a new User Stories in a Project ID#2
            string query = "userstories";
            HttpContent payload = new StringContent("{\"Name\":\"New Story\",\"Project\":{\"Id\":2}}", 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;

            //create a new User Stories in a Project ID#2
            string query = "userstories";
            HttpContent payload = new StringContent("{\"Name\":\"New Story\",\"Project\":{\"Id\":2}}", 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;

            //create a new User Stories in a Project ID#2
            string query = "userstories";
            HttpContent payload = new StringContent("{\"Name\":\"New Story\",\"Project\":{\"Id\":2}}", 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);
            }
        }
    }
}

📘

Adding or updating several Stories at once

You can operate with several Stories at once by using /api/v1/UserStories/bulk endpoint.

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