AddItemExternal Problems

If you are having a problem using Dragnet, post a message here.

Moderator: SourceGear

Locked
BrianP
Posts: 5
Joined: Wed Aug 03, 2005 9:18 pm

AddItemExternal Problems

Post by BrianP » Thu Sep 22, 2005 8:52 pm

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

jclausius
Posts: 3702
Joined: Tue Dec 16, 2003 1:17 pm
Location: SourceGear
Contact:

Post by jclausius » Fri Sep 23, 2005 8:19 am

Is there anything in the Dragnet Server log which may give an indication of the problem?
Jeff Clausius
SourceGear

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

Post by mskrobul » Fri Sep 23, 2005 8:57 am

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:

Code: Select all

CookieContainer cc = new CookieContainer(); 
Dragnet.DragnetWebService dragnetService = new Dragnet.DragnetWebService(); 
dragnetService.CookieContainer = cc; 
dragnetService.Url = "http://localhost/dragnet/dragnetwebservice.asmx"; 
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).
Mary Jo Skrobul
SourceGear

BrianP
Posts: 5
Joined: Wed Aug 03, 2005 9:18 pm

Post by BrianP » Mon Sep 26, 2005 4:10 pm

Thanks for all your help.

When I tried to determine what errors I got in the log, I found that I was getting no errors at the server.

Then I realised that I had not properly initialised the _dragnetService variable. When I fixed that, it successfully added the item.

Thanks again
Brian Price

Locked