Search code examples
testrail

In testrail API how do I get project_id from case data?


I am trying to add a run with the add_run endpoint, but in my automation code I only have the test cases ids but not the project id (which according the the docs is mandatory). Right now I am doing:

  1. get all projects with /get_projects
  2. get all cases /get_cases/{project_id} Then I loop over the cases I get and add the project_id to the case so I could create an add_run with the proper project_id.

This seems like the wrong way to do it. Anybody has a better solution? Also is there a way to create a run without a project_id? for example if I have a sanity run that includes cases from many projects. Any help is appreciated.


Solution

  • You can do the following to get the parent project ID:

    1. get the case by ID and capture value of the suite_id field
    2. get the parent suite by the value of the suite_id field and capture value of the project_id field <--- here you have your project ID and can use it for creating runs.