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

Reading teh content of the section and using the method get_case_fields

Hi

I am new to test rail and I have 2 questions

  1. would like to achieve following thing
    ->getting the content of the sections and tescases (under section)
    is there any api call to achieve this??

  2. I was exploring few available methods like (“get_case_fields”) but I am getting error. I am trying to use the call as below-
    JSONObject c = (JSONObject) client.sendGet(“get_case_fields”);
    System.out.println(c.get(“title”));

Error I have is

Exception in thread “main” java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.simple.JSONObject
at testrail.getMethod.main(getMethod.java:19)

Please help

Hi @VShukla11,
I think there are some mayor mistakes here in you try.

get_case_fields is returning an array of objects (org.json.simple.JSONArray), not a single object, therefore your cast crashes. If you iterate trough the array you will realize, this is the wron endpoint for you, because it delivers information about custom field configuration for test cases, not the cases itself.

What you need is get_cases. By this you get an JSONArray with cases. You need to specify the project and the suite (if you are using multiple suite repository) to get the cases with all it’s information. You can also add a suite_id to reduce the list.

I hope this fits your requirement:

A section itself is an entity having an id, name, description and other info, avalable with get_section. But I guess you’re not talking about this…

Probably it is better to go through the docs first. :innocent: