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

Add_results_for_cases API not working

Hi TestRail Developers,

I have been trying to use the add_results_for_cases API and been debugging what could go wrong, but was not able to figure out the issue.

Here is an example of the curl POST request I am making:
curl -v -X POST -H “Content-Type: application/json” -u “username:password” “https://testrail_endpoint/index.php?/api/v2/add_results_for_cases/1250129” -d
‘{
“results”: [
{
“status_id”: 1,
“case_id”: 7624738
}
]
}’

The error I am getting is {“error”:“Field :results cannot be empty but no valid tests or cases found”}

I checked that the run id: 1250129 is a valid run in the view /index.php?/runs/view/1250129 and the case_id is the correct caseid within that testrun.

I am able to add the result individually using the add_result_for_case API, here is an example:

curl -v -X POST -H “Content-Type: application/json” -u “username:password” “https://testrail_endpoint/index.php?/api/v2/add_result_for_cases/1250129/7624738” -d ‘{“status_id”: 1}’

the response I get using the individual result API is (working):
{“id”:37677335,“test_id”:1445116101,“status_id”:1,“created_by”:4427,“created_on”:1571072761,“assignedto_id”:null,“comment”:null,“version”:null,“elapsed”:null,“defects”:null,“custom_stepresults”:null,“attachment_ids”:}

the testrail version I am using is TestRail v5.7.1.4026

Thanks for the help.

Hello @ryho,

Thank you for reaching out! The error message you received typically indicates either the “results” key was missing, or that no matching ‘test_id’ could be found based on the request body. However, the format looks correct from looking at your example. If you’ve already confirmed you’re indeed using the test case ID and not the test ID (as they’re separate entities) could you please reply with a screenshot of the body of your request to your open ticket you have with us so we can further troubleshoot the error? Thank you and I’ll keep an eye out for your reply!

Hi @denriquez, thanks for the reply. I have attached screenshots of the body for both requests (working (add_result_for_case) and non-working (add_results_for_cases) )

Hi @denriquez, any update on this?

@ryho Thank you for the screenshots. Can you please also send a screenshot of the ticket ID within TestRail that you’re attempting to update? Please send this screenshot to your support ticket that’s open with us as I will be keeping an eye out for your response and may have follow-up questions for you. Thanks!

thanks @denriquez, for some reason I cannot access the support ticket I filed with you guys. I sent you a direct message with the details. Please let me know if you got the information you need.

I’ve found your ticket and am sending you an email shortly!