Automatically add requirements to Quality Center using C#

This is my new project at work. I have to take requirements from an InfoPath document and export them to QC11 (ALM). There are a lot of documentation for VB but not much for C# (which is why I am posting this). There are two parts to this process. First i’ll have to extract data from the InfoPath document and then connect to QC and add the requirements. I’ll post the XML part later. For now, Here’s how you can connect to QC and add a dummy requirement using C#.


//Declare an object of TDCoonection
TDConnection qctd = new TDConnection();
//Pass the QC server URL
qctd.InitConnectionEx("http://yourserver:port/qcbin");
//Connect with the QC
qctd.ConnectProjectEx("domain name", "project name", "userid", "password");
bool check = qctd.LoggedIn;

ReqFactory myReqFactory = (ReqFactory)qctd.ReqFactory;
Req myReq = (Req)myReqFactory.AddItem(DBNull.Value);
myReq.Name = "new requirement";
// 0=Business, 1=Folder, 2=Functional, 3=group, 4=testing
myReq.TypeId = "1";
myReq.ParentId = 0;
myReq.Post();

This entry was posted in C#, QC, Uncategorized. Bookmark the permalink.

2 Responses to Automatically add requirements to Quality Center using C#

  1. vinay says:

    Thanks yar

  2. Manas says:

    Getting invalid cast error in this line:
    qctd.InitConnectionEx(“http://yourserver:port/qcbin”);
    Do you have the solution for this?

Leave a comment