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

Test Rail Api, method get_case


Hello ,
I am using Test Rail Api using C# and i have a problem to use the method get_case
I’ve made the request https:/mysitehere/testrail/index.php?/api/v2/get_case/:case_id and i got the error : {“error”:“Content-Type header missing (use Content-Type: application/json)”}.
A help will be appreciated.


Hi @kadi,

Thanks for your posting. Do you use our official C# API binding?

This would already set the required Content-Type header. If you use a custom integration, you can find the low-level details to access the API here:



I am using http request https:/mysitehere/testrail/index.php?/api/v2/get_case/:case_id
and i don’t really know where to put the content type application/json


You would need to submit this as part of the HTTP headers. What do you use to access the API, our official API binding?



yep i use the official API binding.
and my program content
JObject cases = (JObject)manager.SendGet(“get_cases/1/1”);

then i have that exception: Additional information: TestRail API returned HTTP 400 (“Field :suite_id is a required field.”).
actually, what i want is to list all test cases in my project (id =1), test suite(id=1) in the console



Sure, happy to help. get_cases expects the suite ID as GET parameter as follows:




Thank you, that help me a lot.
I have an another question: is that a way to convert JObject, JSon Object to a type Case in the TestRail API.
Because when i get my case by using
JObject cas = (JObject)manager.SendGet(“get_case/1”);
cas is a json object and if i want to make things like or cas.title it’s not gonna work.


Great to hear that this helped :slight_smile: The API always returns JObject or JArray objects currently but you can simply access properties as follows:


This is loosely typed (but still with a nice/clean syntax) as SendPost and SendGet are generic functions which support all TestRail API methods and you can find a full list of supported properties in the description for each API method:



Thank you @tgurock,
Finally i manage to convert jarray in list by using that :
JArray plans = (JArray)_manager.SendGet(parameter);
List listplans = cases.ToObject<List>();

Now my problem is to access to properties that is not defined in the constructor like plan[“runs”] .
an idea?


JArray plans = (JArray)_manager.SendGet(parameter);
List listCases = plans.ToObject<List>();

this is the exact code


Which API method are you calling exactly? get_cases or get_plan, for example?



it’s get_plan , i found a solution it’s JObject testplan = plan.GetJson();
another question : what can we access to a plan entries like runs
i want to get all my runs from a specific test plan.
thanks for your help


i mean how can we access to a plan entries like runs


The entries attribute returned as part of the get_plan response is an array representing all test plan entries. Each entry contains one or more test runs and this is exposed via the runs attribute on the entry level. Here’s the raw JSON again:

I hope this helps!




I see the same behavior and I think it is a misunderstanding of headers. The documentation says that “Content-Type” is a required header. But for an GET request I have no content and so I need no “Content-Type” header. To specify the wished response format the header “Accept” can be used.



Hi Steffen,

Yes, that’s correct but we simplified the API a bit and use the Content-Type header in all cases. We can recommend using one of the API bindings which take care of the headers, authentication, JSON and UTF-8 encoding and error handling: