Thread

Skip Navigation LinksForums > SpiraTeam Forums > SpiraTeam Issues & Questi... > Remote Access using API

Remote Access using API RSS Feed

Sunday, February 27, 2011

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
Steven HawkesSteven Hawkes
re: Steven Hawkes on Sunday, February 27, 2011
Sunday, February 27, 2011
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>

 

Steven HawkesSteven Hawkes
re: Steven Hawkes on Sunday, February 27, 2011
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
Mike M.Mike M.
re: Steven Hawkes on Sunday, February 27, 2011
Monday, February 28, 2011
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!

Adam SAdam S
re: Mike M. on Monday, February 28, 2011
Tuesday, March 1, 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.

Tagged
Statistics
  • Started: 2/27/2011
  • Last Reply: 3/1/2011
  • Replies: 4
  • Views: 1610
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.