Skip Navigation LinksHome Page > Forums > SpiraTeam Forums > SpiraTeam Issues & Qu... > Remote Access using API
I am trying to connect for the first time to Spirateam from a Visual Studio .NET test project using the following code
ImportExportClient connection = new ImportExportClient();
bool result = connection.Connection_Authenticate("username", "password");
RemoteProject [] projects = connection.Project_Retrieve();
foreach( RemoteProject project in projects)
{
System.Console.WriteLine(project.ProjectId);
}
I get the connection ok to my test environment. Connection_Authenticate returns true but the call to Project_Retreive() fails with the following error.
"The session was not authenticated, please call the Connection_Authenticate() method first"
But as you can see I have called the Connection Authenticate successfully.
There are projects in the SPirateam instance associated to this user.
Any suggestions on hoe to see what the error could be?
TIA
Below is the autogenerated config file.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IImportExport" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/SpiraTeam/Services/v3_0/ImportExport.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IImportExport"
contract="SpiraTeamRef.IImportExport" name="BasicHttpBinding_IImportExport" />
</client>
</system.serviceModel>
</configuration>
ImportExportClient connection = new ImportExportClient();connection.CookieContainer = new CookieContainer();
This creates the storage for cookies, so that on the next request (getting list of projects) the cookies are returned and the system knows you're logged on.
Also, I don't see you checking the result - be sure that 'result' is true, or else you really weren't logged on.
Thanks!
Also since you're using WCF web services, an even easier way would be to simply change:
allowCookies="false" to
allowCookies="true"
in your .config file and that will fix the issue.
And if you have any questions, please email or call us at +1 (202) 558-6885