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

Custom case fields are not working in "get_cases" API


#1

Hello,

I’ve created a new case field (system name: component , type: Multi-select and with the following options:
1, Component 1
2, Component 2
3, Component 3
4, Component 4

and added this components to some test cases.

I want now to get the test cases containing some of these components with API. I’ve tried this:

Is there a way to get only the tests that have a component (Component 1) selected?

Thanks,
Bogdan


#2

Hi Bogdan,

Thanks for your posting. The get_cases API method supports the filters you can find in the API documentation but this currently does not include custom fields:

http://docs.gurock.com/testrail-api2/reference-cases#get_cases

You can read the full list and filter this on the client side of course though and all details required for this are included in the response.

Cheers,
Tobias


#3

Thank you for the quick response. I will filter the test cases from the response.

Cheers,
Bogdan


#4

Thanks, Bogdan, great to hear that this works for you :slight_smile:

Have a good week!

Cheers,
Tobias


#5

When will the API support GETs on custom fields?


#6

Hi Seth!

The API fully supports custom fields, it’s just that there are currently no separate server-side filters for this (it’s planned to look into this). You can already fully filter the list of cases on the client side and the response contains everything you would need for this. We understand that a server-side filter works better for many scenarios of course and I’m happy to add another vote to this feature request, thanks for your feedback!

Cheers,
Tobias


#7

Hi,

I have created a custom field for test case. The field is named Tags (tags_multi_select) and is a multi-select field.

However, when I use get_case API, it does not return this field in the response. Does the API not return multi-select fields?

I have defined other custom fields that are not multi-select and the API returns those fields.

Please let me know.

Thanks,
Tarik


#8

Hi Tarik,

Thanks for your posting. Multi-select fields are only included if a case actually has a value set for this field and this is then returned as array of IDs (as configured in the custom field options). If the response/case does not include the field, you can assume that this field is empty for this case (otherwise the full list is included).

I hope this helps!

Cheers,
Tobias


#9

For the test case I’m getting via the API, i have selected 2 values for this field Tags (tags_multi_select). But when I try to retrieve it via the response it’s null, it’s not being returned even when the field is not empty…
e.g. testCase.get(“tags_multi_select”)


#10

Nevermind, I forgot to precede the field name with “custom”. Now it works!


#11

Hi Tarik,

Ah sorry, missed your previous reply. Yes, custom fields are submitted and accessed with a custom_ prefix via the API but good to hear that you found it yourself already.

Cheers,
Tobias


#12

@tgurock
What’s the status on the API server-side filter for customs?
It’s a pain to download 100 mb each time to filter by custom fields on the client side.

Thanks.