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

API C# advise approach


I would like to create Test Run in TestRail via API with all test cases Type = Automated.
For that purpose I am using nuget TestRail client C# package located:

I need general advise if my approach is good (if i have good API method selected and If I am using it right)
Is it possible from someone to get C# implementation example?

From Json respond it loolk like I need to get type_id.
There seems to be no method which will provide this type id directly so I am looking for a way to play with Json data.

Please let me know how I could play with this Json data and if this is the best approach

POC example:
// List all test cases from test run
Listglobal::TestRail.Types.Test testList = objectTestRail.GetTests(runID);

        int iCount = 0;
        foreach (global::TestRail.Types.Test test in testList)


JSon respond:

“id”: 3013,
“case_id”: 185,
“status_id”: 3,
“assignedto_id”: null,
“run_id”: 24,
“title”: “Remove user from region - wrong PlatformUser”,
“template_id”: 1,
“type_id”: 7,
“priority_id”: 2,
“estimate”: null,
“estimate_forecast”: null,
“refs”: “GP-4141”,
“milestone_id”: null,
“custom_preconds”: “I am on Broker API page\r\nI have wrong PlatformUser\r\nI have ContractorCode\r\nI have RegionCode”,
“custom_steps”: "|||:Step type|:Step definition\r\n|| When | I navigate to Administration section\r\n|| And | open RemoveUserFromRegion method \r\n|| And | type ContractorCode, RegionCode and wrong PlatformUser\r\n|| And | click Try it out! button \r\n|| And | log in as broker user ",
“custom_expected”: “Validation message: Wrong PlatformUser is displayd.”,
“custom_steps_separated”: null,
“custom_mission”: null,
“custom_goals”: null,
“custom_feature”: []


Hi @seba,

Thanks for your posting. We would usually recommend using our official API binding for C#/.NET:

This is loosely typed and makes it easier to use all features the API provides. For example, in your case I would recommend calling get_cases with a type_id filter to get the list of cases with Type = Automated. get_cases expects the ID of the type and you can look this up in TestRail’s administration area on Administration > Customizations. Once you have the list of cases, you can build an array of IDs and pass this to add_run or add_plan to create a run/plan with a custom case selection (attributes: case_ids and include_all):

I hope this helps!