How to create a bug in TFS Programmatically
up vote
0
down vote
favorite
Am looking for a small code snippet which helps me to create a defect in TFS Programmatically using c# VSTS2015.
My TFS Server: http://tfs2.dell.com:8080/tfs/eDell/eDellPrograms/
server is: http://tfs2.dell.com:8080/tfs
Collection is: eDell
Project is: eDellPrograms
Work Item = Defect
Thanks,
Satish D
c# api tfs tfs2012 defects
add a comment |
up vote
0
down vote
favorite
Am looking for a small code snippet which helps me to create a defect in TFS Programmatically using c# VSTS2015.
My TFS Server: http://tfs2.dell.com:8080/tfs/eDell/eDellPrograms/
server is: http://tfs2.dell.com:8080/tfs
Collection is: eDell
Project is: eDellPrograms
Work Item = Defect
Thanks,
Satish D
c# api tfs tfs2012 defects
Why are you trying to do this?
– Yair Halberstadt
Nov 11 at 11:48
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Am looking for a small code snippet which helps me to create a defect in TFS Programmatically using c# VSTS2015.
My TFS Server: http://tfs2.dell.com:8080/tfs/eDell/eDellPrograms/
server is: http://tfs2.dell.com:8080/tfs
Collection is: eDell
Project is: eDellPrograms
Work Item = Defect
Thanks,
Satish D
c# api tfs tfs2012 defects
Am looking for a small code snippet which helps me to create a defect in TFS Programmatically using c# VSTS2015.
My TFS Server: http://tfs2.dell.com:8080/tfs/eDell/eDellPrograms/
server is: http://tfs2.dell.com:8080/tfs
Collection is: eDell
Project is: eDellPrograms
Work Item = Defect
Thanks,
Satish D
c# api tfs tfs2012 defects
c# api tfs tfs2012 defects
asked Nov 11 at 10:44
Satish Dhanaraj
2819
2819
Why are you trying to do this?
– Yair Halberstadt
Nov 11 at 11:48
add a comment |
Why are you trying to do this?
– Yair Halberstadt
Nov 11 at 11:48
Why are you trying to do this?
– Yair Halberstadt
Nov 11 at 11:48
Why are you trying to do this?
– Yair Halberstadt
Nov 11 at 11:48
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You have 2 options:
- TFS Soap API (SDK)
- TFS Rest API
For TFS Soap API (SDK) you need these DLL's:
Microsoft.TeamFoundation.Client;
Microsoft.TeamFoundation.WorkItemTracking.Client;
The code is:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace createNewWorkItem
class Program
static int Main(string args)
Uri collectionUri = new Uri("http://server:8080/TFS/");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["MyProject"];
WorkItemType workItemType = teamProject.WorkItemTypes["Defect"];
WorkItem Defect = new WorkItem(workItemType);
Defect.Title = "TITLE GOES HERE";
Defect.Description = "DESCRIPTION GOES HERE";
Defect.Fields["Issue ID"].Value = "999999";
Defect.Save();
return (Defect.Id);
If you want use Rest API you don't need the above DLL's.
The code is:
public static async void createtWorkItem()
string requestUrl = "http://TFS2015servername:8080/tfs/collectionname/teamprojectname/_apis/wit/workitems/$Defect?api-version=1.0";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(new objectnew
op = "add",
path = "/fields/System.Title",
value = "New Task from TFS 2015 REST API"
);
HttpClientHandler authtHandler = new HttpClientHandler()
// Credentials = CredentialCache.DefaultNetworkCredentials
Credentials = new NetworkCredential("username", "password", "domainname")
;
using (HttpClient client = new HttpClient(authtHandler))
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUrl)
Content = new StringContent(json, Encoding.UTF8,
"application/json-patch+json")
;
HttpResponseMessage hrm = await client.SendAsync(request);
Console.WriteLine("Completed!");
;
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You have 2 options:
- TFS Soap API (SDK)
- TFS Rest API
For TFS Soap API (SDK) you need these DLL's:
Microsoft.TeamFoundation.Client;
Microsoft.TeamFoundation.WorkItemTracking.Client;
The code is:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace createNewWorkItem
class Program
static int Main(string args)
Uri collectionUri = new Uri("http://server:8080/TFS/");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["MyProject"];
WorkItemType workItemType = teamProject.WorkItemTypes["Defect"];
WorkItem Defect = new WorkItem(workItemType);
Defect.Title = "TITLE GOES HERE";
Defect.Description = "DESCRIPTION GOES HERE";
Defect.Fields["Issue ID"].Value = "999999";
Defect.Save();
return (Defect.Id);
If you want use Rest API you don't need the above DLL's.
The code is:
public static async void createtWorkItem()
string requestUrl = "http://TFS2015servername:8080/tfs/collectionname/teamprojectname/_apis/wit/workitems/$Defect?api-version=1.0";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(new objectnew
op = "add",
path = "/fields/System.Title",
value = "New Task from TFS 2015 REST API"
);
HttpClientHandler authtHandler = new HttpClientHandler()
// Credentials = CredentialCache.DefaultNetworkCredentials
Credentials = new NetworkCredential("username", "password", "domainname")
;
using (HttpClient client = new HttpClient(authtHandler))
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUrl)
Content = new StringContent(json, Encoding.UTF8,
"application/json-patch+json")
;
HttpResponseMessage hrm = await client.SendAsync(request);
Console.WriteLine("Completed!");
;
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
add a comment |
up vote
0
down vote
accepted
You have 2 options:
- TFS Soap API (SDK)
- TFS Rest API
For TFS Soap API (SDK) you need these DLL's:
Microsoft.TeamFoundation.Client;
Microsoft.TeamFoundation.WorkItemTracking.Client;
The code is:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace createNewWorkItem
class Program
static int Main(string args)
Uri collectionUri = new Uri("http://server:8080/TFS/");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["MyProject"];
WorkItemType workItemType = teamProject.WorkItemTypes["Defect"];
WorkItem Defect = new WorkItem(workItemType);
Defect.Title = "TITLE GOES HERE";
Defect.Description = "DESCRIPTION GOES HERE";
Defect.Fields["Issue ID"].Value = "999999";
Defect.Save();
return (Defect.Id);
If you want use Rest API you don't need the above DLL's.
The code is:
public static async void createtWorkItem()
string requestUrl = "http://TFS2015servername:8080/tfs/collectionname/teamprojectname/_apis/wit/workitems/$Defect?api-version=1.0";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(new objectnew
op = "add",
path = "/fields/System.Title",
value = "New Task from TFS 2015 REST API"
);
HttpClientHandler authtHandler = new HttpClientHandler()
// Credentials = CredentialCache.DefaultNetworkCredentials
Credentials = new NetworkCredential("username", "password", "domainname")
;
using (HttpClient client = new HttpClient(authtHandler))
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUrl)
Content = new StringContent(json, Encoding.UTF8,
"application/json-patch+json")
;
HttpResponseMessage hrm = await client.SendAsync(request);
Console.WriteLine("Completed!");
;
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You have 2 options:
- TFS Soap API (SDK)
- TFS Rest API
For TFS Soap API (SDK) you need these DLL's:
Microsoft.TeamFoundation.Client;
Microsoft.TeamFoundation.WorkItemTracking.Client;
The code is:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace createNewWorkItem
class Program
static int Main(string args)
Uri collectionUri = new Uri("http://server:8080/TFS/");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["MyProject"];
WorkItemType workItemType = teamProject.WorkItemTypes["Defect"];
WorkItem Defect = new WorkItem(workItemType);
Defect.Title = "TITLE GOES HERE";
Defect.Description = "DESCRIPTION GOES HERE";
Defect.Fields["Issue ID"].Value = "999999";
Defect.Save();
return (Defect.Id);
If you want use Rest API you don't need the above DLL's.
The code is:
public static async void createtWorkItem()
string requestUrl = "http://TFS2015servername:8080/tfs/collectionname/teamprojectname/_apis/wit/workitems/$Defect?api-version=1.0";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(new objectnew
op = "add",
path = "/fields/System.Title",
value = "New Task from TFS 2015 REST API"
);
HttpClientHandler authtHandler = new HttpClientHandler()
// Credentials = CredentialCache.DefaultNetworkCredentials
Credentials = new NetworkCredential("username", "password", "domainname")
;
using (HttpClient client = new HttpClient(authtHandler))
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUrl)
Content = new StringContent(json, Encoding.UTF8,
"application/json-patch+json")
;
HttpResponseMessage hrm = await client.SendAsync(request);
Console.WriteLine("Completed!");
;
You have 2 options:
- TFS Soap API (SDK)
- TFS Rest API
For TFS Soap API (SDK) you need these DLL's:
Microsoft.TeamFoundation.Client;
Microsoft.TeamFoundation.WorkItemTracking.Client;
The code is:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace createNewWorkItem
class Program
static int Main(string args)
Uri collectionUri = new Uri("http://server:8080/TFS/");
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = tpc.GetService<WorkItemStore>();
Project teamProject = workItemStore.Projects["MyProject"];
WorkItemType workItemType = teamProject.WorkItemTypes["Defect"];
WorkItem Defect = new WorkItem(workItemType);
Defect.Title = "TITLE GOES HERE";
Defect.Description = "DESCRIPTION GOES HERE";
Defect.Fields["Issue ID"].Value = "999999";
Defect.Save();
return (Defect.Id);
If you want use Rest API you don't need the above DLL's.
The code is:
public static async void createtWorkItem()
string requestUrl = "http://TFS2015servername:8080/tfs/collectionname/teamprojectname/_apis/wit/workitems/$Defect?api-version=1.0";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string json = serializer.Serialize(new objectnew
op = "add",
path = "/fields/System.Title",
value = "New Task from TFS 2015 REST API"
);
HttpClientHandler authtHandler = new HttpClientHandler()
// Credentials = CredentialCache.DefaultNetworkCredentials
Credentials = new NetworkCredential("username", "password", "domainname")
;
using (HttpClient client = new HttpClient(authtHandler))
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUrl)
Content = new StringContent(json, Encoding.UTF8,
"application/json-patch+json")
;
HttpResponseMessage hrm = await client.SendAsync(request);
Console.WriteLine("Completed!");
;
answered Nov 11 at 13:01
Shayki Abramczyk
2,5071621
2,5071621
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
add a comment |
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
Thank you @Shayki Abramczyk.... the Option1 helped me....
– Satish Dhanaraj
Nov 13 at 11:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247955%2fhow-to-create-a-bug-in-tfs-programmatically%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why are you trying to do this?
– Yair Halberstadt
Nov 11 at 11:48