I am using the code below in an ASPX page to create an Item in Fortress and attach a file to it. I have Fortress installed locally on my dev machine.
The item get's created just fine but the file does not attach. I get the dreaded "Attachment upload failed" message.
The resulting debug info in my browser is:
Attachment upload failed
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Attachment upload failed
Source Error:
Line 85:
Line 86: currMantisItem.AddedAttachments = objAttFullDetailCol;
Line 87: ItemTrackingOperations.ProcessCommandAddFortressItem(currMantisItem);
Line 88:
Line 89: // List the open fortress items again
Source File: c:\Inetpub\wwwroot\AddFortressItem\Default.aspx.cs Line: 87
Stack Trace:
[Exception: Attachment upload failed]
VaultClientOperationsLib.ClientInstance.AddItem(MantisItem& item) +349
VaultClientIntegrationLib.ItemTrackingOperations.ProcessCommandAddFortressItem(MantisItem item) +147
Fortress.FortressTest.AddFortressItem() in c:\Inetpub\wwwroot\AddFortressItem\Default.aspx.cs:87
Fortress.FortressTest.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\AddFortressItem\Default.aspx.cs:35
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
Here is my code:
Code: Select all
// Make a new fortress item
FortressItemExpanded newItem = new FortressItemExpanded();
newItem.ProjectName = projectName;
newItem.Description = "Test Attachment";
newItem.Details = "Some details about the new item.";
newItem.Status = "Open";
newItem.Assignee = "cwolf";
newItem.Resolver = "cwolf";
newItem.Platform = "Unknown";
newItem.ItemType = "Bug";
newItem.TimeEstimate = "Unknown";
newItem.Priority = "Low";
newItem.Validate(); // Call Validate after setting all your strings for your item and before you pass the item to a method.
// Upload some files
MantisItem currMantisItem = newItem.GetMantisItem();
MantisItemAttachmentFullDetail objAtt = new MantisItemAttachmentFullDetail();
MantisItemAttachmentFullDetailColl objAttFullDetailCol = new MantisItemAttachmentFullDetailColl();
objAtt.LocalPath = "C:\\";
objAtt.FileName = "ActExtLog.txt";
objAttFullDetailCol.Add(objAtt);
currMantisItem.AddedAttachments = objAttFullDetailCol;
ItemTrackingOperations.ProcessCommandAddFortressItem(currMantisItem);
Thanks!!
- Chris Wolf