Unable to get Test run details from ALM API

371 Views Asked by At

Using below python code to get all test runs/test instances under a domain and project however it throws an 404 error, able to get the defects not the test runs

import json
import requests
from requests.auth import HTTPBasicAuth
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

almUserName = "007"
almPassword = "@123"
almDomain = "PRO"
almProject = "Mobile"
almURL = "https://alm.com/qcbin/"
qcDefectURL = almURL+"api/domains/"+almDomain+"/projects/"+almProject+"/defects"
qcTestRunURL=almURL+"api/domains/"+almDomain+"/projects/"+almProject+"/runs/?query={name[Run_8-5_00-9-31]}"
print(qcDefectURL)
print(qcTestRunURL)

session = requests.Session()
session.verify = False

auth = session.post(almURL + "authentication-point/authenticate?login-form-required=y",
                auth=HTTPBasicAuth(almUserName, almPassword))
#print("Authentication ", auth, auth.text, session.cookies)

site_session = session.post(almURL + "rest/site-session")
#print("Session ", site_session, site_session.text, session.cookies)

check = session.get(almURL + "rest/is-authenticated")
print("Check ", check, check.text)

# Enforce JSON output
session.headers.update({ 'Accept': 'application/json' })
#projects = session.get(qcDefectURL)
TestRuns=session.get(qcTestRunURL)
print(TestRuns.status_code) 
print(TestRuns.json())

Tried using various links mentioned in blogs and stackoverflow answers(here,here,here), but not able to resolve

Output: {'Id': 'qccore.general-error', 'Title': 'Not Found', 'ExceptionProperties': None, 'StackTrace': None}

1

There are 1 best solutions below

0
Marteng On

Your query URL ends with

/runs/?query={name[Run_8-5_00-9-31]}

but should be like

/runs?query={name[Run_8-5_00-9-31]}

Further reading: https://admhelp.microfocus.com/alm/en/12.55/api_refs/REST_TECH_PREVIEW/ALM_REST_API_TP.html#REST_API_Tech_Preview/General/Filtering.html