Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Bad Request add_results endpoint


#1

I am trying to update a number of test cases in a single test run

Each of my results is stored in a JSONObject and then added to a JSONArray

JSONObject testRailResult = new JSONObject();
testRailResult.put(“test_id”, 21345);
testRailResult.put(“status_id”, 5);
testRailResult.put(“comment”, “Test Failed”);

TEST_RAIL_RESULTS.add(testRailResult);

Once all of my tests have executed I then add the JSONArray to a JSONObject and send:

JSONObject data = new JSONObject()
data.put(“results”, TEST_RAIL_RESULTS);

The data format is:

{“results”:[{“status_id”:5, “comment”:“Test Failed”,“test_id”:21345}]

The error response I am getting is:

TestRail API returned HTTP 400(“Field :results cannot be empty but no valid tests or cases found”)


#2

Thanks for your posting. add_results requires the test ID (T### in the UI). If you have the case IDs instead (C###), you can use add_results_for_cases in combination with the run ID:

http://docs.gurock.com/testrail-api2/reference-results#add_results_for_cases


#3

Thanks for the reply, noticed that error late yesterday.

I now have the add_results and add_results_for_cases endpoints working