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

Get custom field dropdown values


#1

How do I get values for custom fields through API?

I used this: https://testrail.veevadev.com/testrail/index.php?/api/v2/get_case_fields

I got this response:

{
“id”:20,
“is_active”:true,
“type_id”:7,
“name”:“auto_owner”,
“system_name”:“custom_auto_owner”,
“label”:“Automation Ownership”,
“description”:“This field represents the script owner \u2013 script creator or new owner when script ownership is transferred to a new owner.”,
“configs”:[
{
“context”:{
“is_global”:false,
“project_ids”:[
5
]
},
“options”:{
“is_required”:false,
“default_value”:“199”
},
“id”:“1234”
},
{
“context”:{
“is_global”:false,
“project_ids”:[
10,
1,
9,
4,
2,
11
]
},
“options”:{
“is_required”:false,
“default_value”:""
},
“id”:“1234”
}
],
“display_order”:12,
“include_all”:true,
“template_ids”:[

  ]

}

But I need the values for this dropdown as well. I do not see the ‘items’ in API response. Please help.

Thanks.


#2

Hi Kavya,

Thank you for your post. The TestRail API would output any custom fields that you have. If there is data in those fields it should be displayed alongside that field. If there is no data in the field, the field will be displayed with a NULL value. Example:

[
  {
    "id": 1,
    "is_active": true,
    "type_id": 3,
    "name": "preconds",
    "system_name": "custom_preconds",
    "label": "Preconditions",
    "description": "The preconditions of this test case. Reference other test cases with [C#] (e.g. [C17]).",
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": null
        },
        "options": {
          "is_required": false,
          "default_value": "",
          "format": "markdown",
          "rows": "7"
        },
        "id": "4be1344d55d11"
      }
    ],
    "display_order": 2,
    "include_all": false,
    "template_ids": [
      1,
      2
    ]
  },
  {
    "id": 2,
    "is_active": true,
    "type_id": 3,
    "name": "steps",
    "system_name": "custom_steps",
    "label": "Steps",
    "description": "The required steps to execute the test case.",
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": null
        },
        "options": {
          "is_required": false,
          "default_value": "",
          "format": "markdown",
          "rows": "7"
        },
        "id": "4be97c65ea2fd"
      }
    ],
    "display_order": 3,
    "include_all": false,
    "template_ids": [
      1
    ]
  },
  {
    "id": 3,
    "is_active": true,
    "type_id": 3,
    "name": "expected",
    "system_name": "custom_expected",
    "label": "Expected Result",
    "description": "The expected result after executing the test case.",
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": null
        },
        "options": {
          "is_required": false,
          "default_value": "",
          "format": "markdown",
          "rows": "7"
        },
        "id": "4be1345cafd07"
      }
    ],
    "display_order": 4,
    "include_all": false,
    "template_ids": [
      1
    ]
  },
  {
    "id": 10,
    "is_active": true,
    "type_id": 10,
    "name": "steps_separated",
    "system_name": "custom_steps_separated",
    "label": "Steps",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": null
        },
        "options": {
          "is_required": false,
          "format": "markdown",
          "has_expected": true,
          "rows": "5"
        },
        "id": "4be97c65ea2fd"
      }
    ],
    "display_order": 5,
    "include_all": false,
    "template_ids": [
      2
    ]
  },
  {
    "id": 12,
    "is_active": true,
    "type_id": 3,
    "name": "mission",
    "system_name": "custom_mission",
    "label": "Mission",
    "description": "A high-level overview of what to test and which areas to cover, usually just 1-2 sentences.",
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": null
        },
        "options": {
          "is_required": false,
          "default_value": "",
          "format": "markdown",
          "rows": "7"
        },
        "id": "4be1345cafd07"
      }
    ],
    "display_order": 6,
    "include_all": false,
    "template_ids": [
      3
    ]
  },
  {
    "id": 13,
    "is_active": true,
    "type_id": 3,
    "name": "goals",
    "system_name": "custom_goals",
    "label": "Goals",
    "description": "A detailed list of goals to cover as part of the exploratory sessions.",
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": null
        },
        "options": {
          "is_required": false,
          "default_value": "",
          "format": "markdown",
          "rows": "7"
        },
        "id": "4be1345cafd07"
      }
    ],
    "display_order": 7,
    "include_all": false,
    "template_ids": [
      3
    ]
  },
  {
    "id": 17,
    "is_active": true,
    "type_id": 1,
    "name": "case_test_data",
    "system_name": "custom_case_test_data",
    "label": "Test Data",
    "description": null,
    "configs": [],
    "display_order": 4,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 18,
    "is_active": true,
    "type_id": 12,
    "name": "severity",
    "system_name": "custom_severity",
    "label": "Severity",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": false,
          "project_ids": [
            3
          ]
        },
        "options": {
          "is_required": false,
          "items": "1, Option 1"
        },
        "id": "655a1671-aadb-42fd-8cbd-ae09a02d6920"
      }
    ],
    "display_order": 8,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 19,
    "is_active": true,
    "type_id": 12,
    "name": "custom_field_one",
    "system_name": "custom_custom_field_one",
    "label": "Custom Field One",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": [
            4
          ]
        },
        "options": {
          "is_required": false,
          "items": "1, Option 1\n2, Option 2\n3, Option 3"
        },
        "id": "aa0ba444-7d53-47f6-bab4-b26d8a5fa57a"
      }
    ],
    "display_order": 9,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 20,
    "is_active": true,
    "type_id": 12,
    "name": "multi_select",
    "system_name": "custom_multi_select",
    "label": "Multi-Select",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": [
            3,
            4
          ]
        },
        "options": {
          "is_required": false,
          "items": "1, Option 1\n2, Option 2\n3, Option 3"
        },
        "id": "7e668faf-1c00-4992-b45c-c3abc36f8eac"
      }
    ],
    "display_order": 10,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 22,
    "is_active": true,
    "type_id": 5,
    "name": "check_box",
    "system_name": "custom_check_box",
    "label": "Check Box",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": []
        },
        "options": {
          "is_required": false,
          "default_value": "0"
        },
        "id": "fa24ab6b-9564-4e1f-ae36-6d104ec8a34e"
      }
    ],
    "display_order": 5,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 23,
    "is_active": true,
    "type_id": 6,
    "name": "drop_down",
    "system_name": "custom_drop_down",
    "label": "Dropdown",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": []
        },
        "options": {
          "is_required": false,
          "default_value": "1",
          "items": "1, Option 1\n2, Option 2\n3, Option 3"
        },
        "id": "e63c3028-686d-42bd-9100-883d3ca7ef62"
      }
    ],
    "display_order": 6,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 24,
    "is_active": true,
    "type_id": 1,
    "name": "string_field",
    "system_name": "custom_string_field",
    "label": "String Field",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": []
        },
        "options": {
          "is_required": false,
          "default_value": ""
        },
        "id": "78e138aa-4a2b-42d1-a9e7-e031f0302dc0"
      }
    ],
    "display_order": 7,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 26,
    "is_active": true,
    "type_id": 3,
    "name": "case_changes",
    "system_name": "custom_case_changes",
    "label": "Changes",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": []
        },
        "options": {
          "is_required": false,
          "default_value": "Enter changes here",
          "format": "markdown",
          "rows": "10"
        },
        "id": "f26d01c2-1e1d-46a1-884f-14d67f0797d8"
      }
    ],
    "display_order": 11,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 27,
    "is_active": true,
    "type_id": 1,
    "name": "references_two",
    "system_name": "custom_references_two",
    "label": "Reference Title",
    "description": "This field is for additional references",
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": []
        },
        "options": {
          "is_required": false,
          "default_value": ""
        },
        "id": "41fde966-91d4-45ea-bf82-5b8567a8ea4b"
      }
    ],
    "display_order": 8,
    "include_all": true,
    "template_ids": []
  },
  {
    "id": 28,
    "is_active": true,
    "type_id": 6,
    "name": "milestone_introduced",
    "system_name": "custom_milestone_introduced",
    "label": "Milestone Introduced",
    "description": null,
    "configs": [
      {
        "context": {
          "is_global": true,
          "project_ids": []
        },
        "options": {
          "is_required": false,
          "default_value": "",
          "items": "1, Milestone 1\n2, Milestone 2\n3, Milestone 3"
        },
        "id": "c181970a-cae4-4dae-b0e1-c33758af101f"
      }
    ],
    "display_order": 9,
    "include_all": true,
    "template_ids": []
  }
]

In the above example you can see all of my custom fields showing up and they include all possible options that are available for that custom field. Is there a specific custom field you are not seeing or are you seeing the custom field but not the available values?


#3

Hi Marty,

Thank you for the reply,

I see the custom field but not the values in the api response. I can see the values through the UI though. But not via API.


#4

There are other custom fields whose values I could see through API but not for this one.