Authentication failed using Python for SpiraTest (v7.6.1.0)

Monday, September 2, 2024
Avatar


Hello,

I believe something was changed after the update of SpiraTest (v7.6.1.0)
Currently  I'm trying to figure out how to fix it. Previously the following code used to work:

import requests
RUNNER_LINK = f"https://company.co.uk/SpiraTest/Services/v7_0/RestService.svc"
api_key = '{B303FEC2-XXX-XXXX-XXXX-E1C9A891725F}'
username = "SmithJ"
RUNNER_NAME = "John Smith"
params = {'username': username,   'api-key':api_key}
headers = {'accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent':RUNNER_NAME}
uri = "users"
get_users = requests.get(f'{RUNNER_LINK}/{uri}',  params=params, headers=headers)
print(get_users)


I get response:

<Response [400]>

Which means: The HTTP 400 Bad Request client error response status code indicates that the server would not process the request due to something the server considered to be a client error. The reason for a 400 response is typically due to malformed request syntax, invalid request message framing, or deceptive request routing

Note 
    1. "api_key" copied form RSS / API Key.
    2. Enable RSS Feeds: Yes


Do I need to add LDAP DN (CN=SmithJ,OU=Development,OU=companyUsers,DC=company,DC=co,DC=uk) into the params of to the header?

Potentially it could be caused by the company setting/permission.

Best Regards,
N

 

2 Replies
Monday, September 2, 2024
Avatar
re: new_spiratest_user Monday, September 2, 2024

Also when I've tried to use the link directly

 https:/company.co.uk/SpiraTest/Services/v7_0/RestService.svc/projects?username=fredbloggs&api-key={B303FEC2-XXX-XXXX-XXXX-E1C9A891725F}

I received the following message:

The server encountered an error processing the request. The exception message is 'Access is denied.'. See server logs for more details. The exception stack trace is:

at System.ServiceModel.Dispatcher.AuthorizationBehavior.Authorize(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Monday, September 2, 2024
Avatar
re: new_spiratest_user Monday, September 2, 2024

Please check the Event Log inside Spira for the first case, it will provide more information on what is causing the issue.

The second one looks like you are using a sample user 'fredbloggs' and so that makes sense that you are getting an authorization error.

Note that there were no breaking changes in our API in v7.6.1.0, in fact we deliberately version our APIs to avoid this.

If that doesn't help, please log a support ticket with us.

Regards

David

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Monday, September 2, 2024
  • Last Reply: Monday, September 2, 2024
  • Replies: 2
  • Views: 172