Remote Access using API

Sunday, February 27, 2011 3:57:43 PM

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  

 

4 Replies
Sunday, February 27, 2011 4:21:15 PM
Avatar
re: ahawks on Sunday, February 27, 2011 3:57:43 PM
Steven Hawkes

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?

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>

 

Sunday, February 27, 2011 4:41:03 PM
Avatar
re: ahawks on Sunday, February 27, 2011
Please can you also tell me if there is a possibility to switch on logging and where I can see the log files for Spirateam fro external access
Monday, February 28, 2011 3:39:33 PM
Avatar
re: ahawks on Sunday, February 27, 2011 3:57:43 PM
Hello Steven,

Authentication information is stored in cookies. Therefore, before calling the Connection_Authenticate(), be sure to create a cookie container -

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!

Wednesday, March 2, 2011 1:53:20 AM
Avatar
re: inflectra.mike on Monday, February 28, 2011

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.

Statistics
  • Started: Sunday, February 27, 2011 3:57:43 PM
  • Last Reply: Wednesday, March 2, 2011 1:53:20 AM
  • Replies: 4
  • Views: 1766