Examples for AddItemExternal() Web Service API

A collection of information about Dragnet, including solutions to common problems.

Moderator: SourceGear

Locked
mskrobul
Posts: 490
Joined: Wed Jan 14, 2004 10:22 am
Location: SourceGear
Contact:

Examples for AddItemExternal() Web Service API

Post by mskrobul » Wed Dec 15, 2004 5:32 pm

MantisItem Example

These are the parameters that are available/required/optional for the MantisItem object . You should be able to determine the IDs for category, platform etc by looking at the page source for the AddItemExternal (or any page that lists these values) page and the project ID is in the URL of any page in the Dragnet project.

MantisItem mItem = new MantisItem();
mItem.ProjectID = nProjectID; //required int
mItem.Description = strDescription; //required string
mItem.CategoryID = nCategoryID; //required int
mItem.PriorityID = nPriorityID; // required int
mItem.ItemAccessType = dragnetService.AccessType.Public (or dragnetService.AccessType.Private) //required AccessType
mItem.Details = strDetails; // required string
mItem.Version = strVersion; // optional string
mItem.PlatformID = nPlatformID; //required int
mItem.TypeID = nTypeID; // required int
mItem.Custom1 = strCustom1; //optional string
mItem.Custom2 = strCustom2; //optional string
mItem.Attachments = attachments;// optional
mItem.StatusID = nStatusID; //required for ModifyItem() - this value is automatically set to "open" for AddItemExternal() and AddItem()
mItem.AssigneeID = nAssigneeID; //required for AddItem() - this value is automatically set to "external user ID" for AddItemExternal()
MantisItemAttachmentFullDetail Array see below

Dragnet doesn't allow external users to set certain values because external users shouldn't have that much control over issues in Dragnet.
When you use the AddItemExtnernal() method, the Assignee, Milestone, Priority and Time Estimate values will always be set to the default values. If you want to set these values, you must use the AddItem() web service call, which requires a login.

Get Attachment Example:

MantisItemAttachmentFullDetail mifd = new MantisItemAttachmentFullDetail();
System.Web.UI.HtmlControls.HtmlInputFile fileUpload; //assuming this control is on the ASP.NET page

mifd.AttStream = fileUpload.PostedFile.InputStream; //required System.IO.InputStream
mifd.ContentType = fileUpload.PostedFile.ContentType; //required string
mifd.FileCRC = 0; //this can just be zero
mifd.FileLength = fileUpload.PostedFile.ContentLength; //Required long
mifd.Description = strDescription; //optional string
mifd.FileName = strFilename; //required string - filename only, not the full path
mItem.Attachments = new MantisItemAttachmentFullDetail[] {mifd};

Simple WebService Example

//The following assumes Dragnet is the name of the web reference

CookieContainer cc = new CookieContainer();
Dragnet.DragnetWebService dragnetService = new Dragnet.DragnetWebService();
dragnetService.CookieContainer = cc;
dragnetService.Url = "http://localhost/dragnet/dragnetwebservice.asmx";

int ret = -1;
Dragnet.MantisItem mi = new Dragnet.MantisItem();
mi.CategoryID = 0;
mi.Description = "External Add sample";
mi.Details = "External Add sample details";
mi.PlatformID = 1;
mi.TypeID = 2;
mi.Version = "1.0";
mi.ProjectID = 101;

ret = dragnetService.AddItemExternal(mi);


//returns 0 on success

Some return codes:
-1 = Invalid
0 = Sucess
1 = Failure
2 = Feature Not Implemented
3 = InvalidData

//general errors
Fail Incorrect Password = 1001;
Fail Invalid User = 1002;
Fail Not Authenticated = 1003;
Fail Session Timeout = 1004;
Fail Inactive User = 1005;
Fail Invalid AuthToken = 1006;
Fail Invalid Smtp Server = 1007;
Fail Invalid Credentials = 1008;
Fail Project Permission Denied = 1009;
Fail Not Enough Licenses = 1015;
Fail Invalid Serial = 1016;

//Database errors
Fail DB Conn = 1101;
Fail DB Insert = 1102;
Fail DB Delete = 1103;
Fail DB Transaction = 1104;
Fail DB Reader = 1105;
Fail DB Update = 1106;
Fail DB Delete System Item = 1107;
Fail DB Name Conflict = 1108;

//Specific Errors
Fail Project ID Not Found = 1407;
Fail DB FileStream = 1501;
FailInvalidFileStream = 1502;
Fail DB Attachment Insert = 1503;
Mary Jo Skrobul
SourceGear

Locked