Update existing or create a new Bug
More information
To update a Bug you have to know its ID.
To add a new Bug you have to know ID of its Project.
If you'd like to connect a Bug to some resources (EntityState, Team, Owner, Iteration, Release, etc.) you have to know their IDs.
Here are some popular queries:
-
change state for Bug ID#23
GET to /api/v1/bugs/23?include=[EntityState[NextStates]] (to know ID of the state)
POST to /api/v1/bugs/194 payload {"EntityState":{"Id":97}} -
set value "4.5" for custom field "Found in release" for Bug ID#209
POST TO /api/v1/bugs/209 payload {"CustomFields":[{"Name":"Found in release","Value":"4.5"}]} -
add a new comment for Bug ID#23
POST to /api/v1/comments payload {"Description":"New comment","General":{"Id":23}} -
add time spent for Bug ID#23
POST to /api/v1/times payload {"Spent":2,"Remain":1,"Description":"Some work","Role":{"Id":1},"Assignable":{"Id":23}} -
estimate Bug ID#23 (5 story points for Developer, 2 story points for QA)
POST to /api/v1/bugs/194 payload {"Roleefforts":[{"Role":{"Id":1},"Effort":5},{"Role":{"Id":9},"Effort":2}]} -
add a Bug to Project ID#2 and assign User ID#6 as Developer
POST to /api/v1/bugs payload {"Name":"New bug","Project":{"Id":2},"Assignments":[{"GeneralUser":{"Id":6},"Role":{"Id":1}}]} -
add a Bug to Project ID#2, assign User ID#6 as Developer and estimate development work with 10 story points
POST to /api/v1/bugs payload {"Name":"New bug","Project":{"Id":2},"Assignments":[{"GeneralUser":{"Id":6},"Role":{"Id":1}}],"Roleefforts":[{"Role":{"Id":1},"Effort":10}]} -
set planned dates for several Bugs (ID#179 and ID#181)
POST to /api/v1/Bugs/bulk payload [{"Id":179,"PlannedStartDate":"2017-03-19","PlannedEndDate":"2017-08-29"},{"Id":181,"PlannedStartDate":"2017-03-19","PlannedEndDate":"2017-08-29"}] -
create several Bugs for Feature ID#206
GET to /api/v1/features/206?include=[Project] (to know ID of the project)
POST to /api/v1/Bugs/bulk payload [{"Project":{"Id":192},"Name":"First Bug","Feature":{"Id":206}},{"Project":{"Id":192},"Name":"Second Bug","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 Bug in Project ID#2
string query = "bugs";
HttpContent payload = new StringContent("{\"Name\":\"New Bug\",\"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 Bug in Project ID#2
string query = "bugs";
HttpContent payload = new StringContent("{\"Name\":\"New Bug\",\"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 Bug in Project ID#2
string query = "bugs";
HttpContent payload = new StringContent("{\"Name\":\"New Bug\",\"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 Bug in Project ID#2
string query = "bugs";
HttpContent payload = new StringContent("{\"Name\":\"New Bug\",\"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 Bugs at once
You can operate with several Bugs at once by using /api/v1/bugs/bulk endpoint.