1

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}

Vinod
  • 376
  • 2
  • 11
  • 34
  • You can follow the debugging steps, the value you are printing for qcTestRunURL, copy the URL and paste it into a web browser. It will ask for your username and password. See, if it returns the value. My wild guess is something wrong with the URL – Barney Aug 07 '21 at 07:20
  • Yes I tried that as well, even that throws "website not found" error, how to correct the URL? – Vinod Aug 07 '21 at 07:37
  • As I tried various links mentioned in various sites – Vinod Aug 07 '21 at 07:44
  • Can you update your question with the version of ALM that you are currently using? You may need to use a cross filter to fetch the information of a test run since runs are tied to a suite – Barney Aug 07 '21 at 12:06
  • Check this out, https://admhelp.microfocus.com/alm/api_refs/REST_TECH_PREVIEW/Content/REST_API_Tech_Preview/General/Filtering.html – Barney Aug 07 '21 at 12:07

1 Answers1

0

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

Marteng
  • 1,179
  • 13
  • 31