Get All Defects

Applies to QAComplete 14.3, last modified on February 19, 2024

The sample code below shows how to use the Bugs_LoadByCriteria operation to get all defects in your project in QAComplete. The operation gets a list of defects that meet the condition you specify. If no condition is specified, the operation gets all defects registered in your project.

You can get items of another type (releases, requirements, and so on) the same way you get defects. To do this, use the appropriate operation. For example, to get all releases registered in your project, use the Releases_LoadByCriteria operation; to get all requirements, use the FunctionalSpecs_Load operation and so on. For information on operations you can use to get desired items, see API Reference.

C#

string login = "[email protected]";
string password = "p@ssword";
int projID = 10372;

// To get all defects, specify an empty condition
string condition = "";
// Specify sorting
string sorting = "Title";
int pageSize = 200;

ServiceSoapClient service = new ServiceSoapClient();
try
{
   // Prepare AuthenticationData
   LoginInfo loginInfo = service.GetLoginInfo("", login, password);
   AuthenticationData authData = new AuthenticationData();
   authData.AppCode = loginInfo.AppCode;
   authData.UserId = loginInfo.UserId;
   authData.PassCode = password;
   authData.DeptId = loginInfo.DeptId;
   authData.ProjId = projID;

   Bug[] bugs;
   int pageNumber = 1;
   do
   {
      bugs = service.Bugs_LoadByCriteria(authData, condition, sorting, pageSize, pageNumber);
      foreach (Bug bug in bugs)
      {
         Console.WriteLine("{0}: {1}", bug.BugId, bug.Title);
      }
      pageNumber++;
   }
   while (bugs.Length == pageSize);
}
catch (FaultException e)
{
   MessageFault msgFault = e.CreateMessageFault();
   string error = msgFault.GetReaderAtDetailContents().GetAttribute("Text");

   Console.WriteLine(error);
}

Java

import java.util.List;
import javax.xml.ws.soap.SOAPFaultException;

String login = "[email protected]";
String password = "p@ssword";
int projID = 10372;

// To get all defects, specify an empty condition
String condition = "";
// Specify sorting
String sorting = "Title";
int pageSize = 200;

ServiceSoap service = new Service().getServiceSoap12();

try {
   // Preparing AuthenticationData
   LoginInfo loginInfo = service.getLoginInfo("", login, password);
   AuthenticationData authData = new AuthenticationData();
   authData.setAppCode(loginInfo.getAppCode());
   authData.setUserId(loginInfo.getUserId());
   authData.setPassCode(password);
   authData.setDeptId(loginInfo.getDeptId());
   authData.setProjId(projID);

   List<Bug> bugs;
   int pageNumber = 1;
   do {
      bugs = service.bugsLoadByCriteria(authData, condition, sorting, pageSize, pageNumber).getBug();
      for (Bug bug : bugs) {
         System.out.format("%d: %s%n", bug.getBugId(), bug.getTitle());
      }
      pageNumber++;
   } while (bugs.size() == pageSize);
} catch (SOAPFaultException e) {
   e.printStackTrace();
}

See Also

Bugs_LoadByCriteria Operation
How To Get Items
How To

Highlight search results