xGeo
xGeo

Reputation: 2139

How to attach files to Mantis Connect mc_issue_add

Im wondering if I can attach files using filename on MantisConnect. I've tried the ff without luck.

var mc = new MantisBt.Service.Client.MantisBt.Api.MantisConnect();
IssueData iIssue = new IssueData() {
    //some other properties here...
    attachments = new AttachmentData[] { 
                          filename = "path-to-my-attachment",
                          date_submitted = DateTime.Now 
                  }
};
string issueID = mc.mc_issue_add(MyUserID, MyPassword, iIssue);

The issue was posted in Mantis but the attachment is not added. I'm sure that the "path-to-my-attachment" exists: (FileInfo.Exists == true)

I have also tried:

IssueData iIssue = new IssueData();
//some other properties here
iIssue.attachments = 
//tried converting a List<AttachmentData> to array
//tried the usual AttachmentData[] method
//tried adding AttachmentData["length here"]

but the same thing, issue is posted, no attachments added.

Anyone?

Upvotes: 0

Views: 409

Answers (2)

xGeo
xGeo

Reputation: 2139

I figured out that somehow, populating the attachments property of IssueData and saving the issue via mc_issue_add or mc_issue_update does not save the attachments. only way is to save the issue first, use the id then use mc_issue_attachment_add.

So NO. you cannot use the attachments property to add bulk attachments. you need to add them one-by-one using mc_issue_attachment_add.

Upvotes: 0

Robert Munteanu
Robert Munteanu

Reputation: 68308

The function you're looking for is mc_issue_attachment_add, mc_issue_add and mc_issue_update don't allow adding attachments.

Upvotes: 1

Related Questions