pythonrallypyral

error in connecting Rally from python via pyral using API key


My organization uses SSO authentication. I am getting error while trying to connect rally using api key from python via pyral. Not sure what i am doing wrong. Any help is appreciated! I am using below code in the sample.py file (only change is I am entering the API key value, workspace name and project name) -

import sys
from pyral import Rally, rallyWorkset
options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args    = [arg for arg in sys.argv[1:] if arg not in options]
server, user, password, apikey, workspace, project = rallyWorkset(options)
print(server)
rally = Rally('rally1.rallydev.com', apikey='<my api key>', workspace='<workspace name>', project='<project name>')
rally.enableLogging('mypyral.log')
workspaces = rally.getWorkspaces()
for wksp in workspaces:
    print("%s %s" % (wksp.oid, wksp.Name))
    projects = rally.getProjects(workspace=wksp.Name)
    for proj in projects:
        print("%12.12s  %s" % (proj.oid, proj.Name))

ERROR I am getting -

rally1.rallydev.com
Traceback (most recent call last):
  File "sample.py", line 10, in <module>
    rally = Rally('rally1.rallydev.com', apikey='<my api key>', workspace='<workspace name>', project='<project name>')
  File "C:\...\Python\Python36\lib\site-packages\pyral\restapi.py", line 259, in __init__
    self.contextHelper.check(self.server, wksp, proj, self.isolated_workspace)
  File "C:\...\Python\Python36\lib\site-packages\pyral\context.py", line 171, in check
    user_response = self._getUserInfo()
  File "C:\...\Python\Python36\lib\site-packages\pyral\context.py", line 276, in _getUserInfo
    raise RallyRESTAPIError(problem)
pyral.context.RallyRESTAPIError: Target Rally host: 'rally1.rallydev.com' non-existent or unreachable

Solution

  • the issue was resolved after below steps -