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

[API] Methods returning values, instead of index of dropdowns?


#1

Hi,
I am wondering, is there a way to get the actual selected values of a dropdown
For example when sending a GET request to get_test I want to retrieve the values of the selected option of two custom drop-downs, instead of their indexes?
Thanks


#2

Hello Kosmoo,

Thanks for your posting. You can get the actual values for the dropdown indexes by reading the custom field definitions. Depending on the entity you added the custom field for (cases or tests/results), you can either use get_case_fields or get_result_fields for this:

http://docs.gurock.com/testrail-api2/reference-cases-fields
http://docs.gurock.com/testrail-api2/reference-results-fields

I hope this helps!

Regards,
Tobias


#3

I see, so the only way to get the selected value is by calling both get_test and get_case_fields and then matching the index.

I was hoping for something simpler, but that will work.

Thanks!


#4

Hello Kosmoo,

Great to hear that this works for you and please let me know in case you have any questions.

Regards,
Tobias


#5

Kosmoo,

I have found it helpful to get the values of the various drop downs I’m using and cacheing them. That way it is only a look-up when I actually make the request and you don’t have to do a GET each time.


#6

Hello Ryan,

Thanks for your posting. Yes, that’s a good idea in general and we can also recommend this for other API methods that return meta data, such as get_priorities or get_statuses, for example (which change rarely if at all).

Thanks again,
Tobias