Hi Gopinath,
There isn't a way in a single WSAPI query to get both test-cases along with the actual details of their associated defects. You will need to execute two queries, one (as you're doing) to get the test-cases, the other to get the details of their defects fetching the defect fields you need.
The reason you can't combine it to a single query is that Rally's REST API allows posting to a single URL which is associated with a single endpoint (object type). The URL to query a Defect will be: //URL/slm/webservice/v2.0/Defect? ... ... ... while for TestCase it is //URL/slm/webservice/v2.0/TestCase? ... ...
The 'Defects' field that you see in the TestCase object is only a reference to a collection of defects associated to that test-case, it only provides you the count of this collection and a reference (_ref) to bring up this collection in a subsequent query.
You have two options to get the details of these defects associated to your test-case: Either query the collection URL by its provided reference, or you can query the Defect endpoint with a filter such as: query=(TestCase.FormattedID = "TCID001") , this will get you the same defects. But either way, it will be a separate query of the one looking up the testcase itself.
I hope this helps. Please let us know.
Sagi
Original Message:
Sent: Jan 12, 2022 09:50 PM
From: Gopinath Nagarajan
Subject: How to GET Rally API testcases & defects with one query ?
How to GET Rally API testcases & defects details with one query ?
Below GET API returns Full testcase Object classes but defects objects are very minimal . Only _ref objects are available for defects. I am looking for Defect name , FormattedID and Owner along with testcase details . Appreciate your help here. Thank you
https://URL/slm/webservice/v2.0/TestCase?query=(FormattedID = "TCID01")&
fetch=Name,FormattedID,Defects,Description,Objective,Notes,LastRun&order=LastRun desc
"_rallyAPIMajor": "1", "_rallyAPIMinor": "26", "_ref": "https://rally1.rallydev.com/slm/webservice/1.26/task/9872916743.js", "_refObjectName": "Update XYZ when ABC", "_type": "Task"}