Problems with AddItemExternal
We are trying to move our old issue database into Dragnet using the webservice interface following http://support.sourcegear.com/viewtopic.php?t=2568. I am currently using VS2005 Beta 2 and C# to interface to the service.
I managed to get Login with DragnetWebService API http://support.sourcegear.com/viewtopic.php?t=2775 to work.
However, when using AddItemExternal I have experienced problems.
Firstly, the example given at the link above failed with an SQL Foreign Key constraint. I traced this to item.PriorityID being 0. Changed it to a value found in the itempriorities table.
Next, I run it and it get an Exception thrown. NullReferenceException.
The C# code that I am using is
public bool AddItem()
{
MantisItem item;
int result;
item = new MantisItem();
item.ProjectID = 101;
item.Description = "Test External Item import";
item.CategoryID = 2;
item.ItemAccessType = DragnetImp.dragnet.AccessType.Public;
item.Details = "This issue is being pushed in via the Web Service interface";
item.Version = ""; // optional int
item.PlatformID = 2; //required int
item.TypeID = 3; // required int
item.PriorityID = 3;
item.ReporterID = 101;
item.ResolverID = 102;
result = _dragnetService.AddItemExternal( item );
Console.WriteLine(" AddItem return {0}", result);
return (result == 0);
}
Note also, that the example states that Version is an optional int - in fact, it is a string.
Thanks
Brian Price
AddItemExternal Problems
Moderator: SourceGear
Also, just FYI, you do not need to actually login to the webservice when using AddItemExternal(). You can just use the following code to initiate the web service for AddItemExternal:
If you are actually logging into the web service you just can use AddItem() to add items. This will give you more control over the items added. There are some fields that cannot be assigned to with AddItemExternal.
The following fields will always be the defaults regardless of how you have them set in your code if yo use AddItemExternal():
ReporterID (will always be external user)
AssigneeID (will always be none)
MilestoneID (will always be none)
StatusID (will always be open)
PriorityID (will always be unknown)
TimeEstimateID (will always be unknown)
If you use AddItem() you can set these values (other than status id, which will always be open, and reporter id which will be the logged in user).
Code: Select all
CookieContainer cc = new CookieContainer();
Dragnet.DragnetWebService dragnetService = new Dragnet.DragnetWebService();
dragnetService.CookieContainer = cc;
dragnetService.Url = "http://localhost/dragnet/dragnetwebservice.asmx";
The following fields will always be the defaults regardless of how you have them set in your code if yo use AddItemExternal():
ReporterID (will always be external user)
AssigneeID (will always be none)
MilestoneID (will always be none)
StatusID (will always be open)
PriorityID (will always be unknown)
TimeEstimateID (will always be unknown)
If you use AddItem() you can set these values (other than status id, which will always be open, and reporter id which will be the logged in user).
Mary Jo Skrobul
SourceGear
SourceGear