Get List of Files Attached to Item

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

The sample code below shows how to use the Attachments_GetAttachmentsList operation to get a list of files attached to a defect in your project in QAComplete. The EntityCode and FKId parameters of the operation specify the module (application name) and the ID of the defect whose attachments you want to get.

You can use the operation to get files attached to items of other types (releases, requirements, and so on) the same way you get the defect’s attachments. Specify the appropriate values for the EntityCode and FKId parameters to get files attached to a desired item.

C#

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

string entityCode = "Bugs";
int defectId = 16;

ServiceSoapClient service = new ServiceSoapClient();

// Preparing 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;

Attachment[] attachments = new Attachment[0];

// Getting a list of attachments
attachments = service.Attachments_GetAttachmentsList(authData, entityCode, defectId);
foreach (Attachment attach in attachments)
{
  Console.WriteLine("{0}: {1}", attach.AttachmentId, attach.FileName);
}

Java

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

String entityCode = "Bugs";
int defectId = 16;

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

// 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 <Attachment> attachments;

// Getting a list of attachments
attachments = service.attachmentsGetAttachmentsList(authData, entityCode, defectId).getAttachment();
for (Attachment attachment : attachments) {
  System.out.format("%d: %s%n", attachment.getAttachmentId(), attachment.getFileName());
}

See Also

Attachments_GetAttachmentsList Operation
How To Get Items
How To

Highlight search results