Search code examples
c#mantis

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?


Solution

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