This knowledge base article describes how to connect to the SpiraTest, SpiraPlan & SpiraTeam SOAP web services using .NET code written in C#. The code assumes that you're using Visual Studio 2008 or later and are using the newer .NET 3.0+ Windows Communication Foundation (WCF) "Add Service Reference" rather than the older .NET 2.0 ASMX web service client.

The following code will connect to Spira, authenticate, connect to a project and then get a list of incidents fixed in a specific release:

   //Instantiate the web-service proxy class and set the URL from the .config file
spiraImportExport = new TestSuite.SpiraImportExport30.ImportExportClient();
   spiraImportExport.Endpoint.Address = new EndpointAddress("http://servername/SpiraTest/Services/v3_0/ImportExport.svc");

   //Configure the HTTP Binding to handle session cookies
   BasicHttpBinding httpBinding = (BasicHttpBinding)spiraImportExport.Endpoint.Binding;
   httpBinding.AllowCookies = true;
   httpBinding.Security.Mode = BasicHttpSecurityMode.None;

   //Next lets authenticate and connect to the project
   int projectId = 1;
   spiraImportExport.Connection_Authenticate("username", "password");

   //Now lets get a list of incidents fixed in Release RL00005
   int releaseId = 5;
   List<RemoteFilter> remoteFilters = new List<RemoteFilter>();
   RemoteFilter remoteFilter = new RemoteFilter();
   remoteFilter.PropertyName = "ResolvedReleaseId";
   remoteFilter.IntValue = releaseId;
   RemoteSort remoteSort = new RemoteSort();
   remoteSort.PropertyName = "Name";
   remoteSort.SortAscending = true;
   List<RemoteIncident> remoteIncidents = spiraImportExport.Incident_Retrieve(remoteFilters.ToArray(), remoteSort, 1, 999999);

   //Loop through and display ID, name and description
   foreach (RemoteIncident remoteIncident in remoteIncidents)

Article Info
  • Last Updated: 7/5/2012
  • Article ID: KB3
  • Views: 4657