Forum Discussion

ihsb's avatar
ihsb
New Contributor
4 years ago

Returning customfield names instead of ID via API

On Zephyr Scale 8.0.2, the /testcase/search API returns a customFieldValues field (despite the API doc mentioning it as customFields). This only shows the ID of the customfield and selected option for a Single List.

For example -

"customFieldValues": [
    {
        "intValue": 420,
        "customFieldId": 138
    },
    {
        "intValue": 425,
        "customFieldId": 139
    }
]

This is useless until you call /project/{project_id}/customfields/{component} (which is undocumented) and properly map it to something meaningful. Unless I'm mistaken, this seems to be the method I could find. Is there any other way to do it to reduce the code on our end?

  • Hi, ihsb! Thanks for your question.

    In the latest version of the app (8.0.3), you can use the REST API and get all the information related to custom fields.

     

    For example, GET /rest/atm/1.0/testcase/search?query=projectKey = "{{projectKey}}" AND folder = "/{{folderName}}" should result in a response similar to this one:

     

    [
        {
            ...
            "customFields": {
                "datepicker": "2019-02-20T03:00:00.000Z"
            },
            ...
            "testScript": {
                ...
                "type": "STEP_BY_STEP",
                "steps": [
                    {
                        "testData": "",
                        "customFieldValues": [
                            {
                                "booleanValue": true,
                                "id": 126265,
                                "customField": {
                                    "archived": false,
                                    "name": "checkbox - ts",
                                    "index": 0,
                                    "id": 38,
                                    "type": "CHECKBOX",
                                    "projectId": 10007,
                                    "required": false
                                }
                            }
                        ],
                    }
                ]
            },
        }
    ]

     

     

    Do you see a different response schema when trying this endpoint?

  • jfelix's avatar
    jfelix
    SmartBear Alumni (Retired)

    Hi, ihsb! Thanks for your question.

    In the latest version of the app (8.0.3), you can use the REST API and get all the information related to custom fields.

     

    For example, GET /rest/atm/1.0/testcase/search?query=projectKey = "{{projectKey}}" AND folder = "/{{folderName}}" should result in a response similar to this one:

     

    [
        {
            ...
            "customFields": {
                "datepicker": "2019-02-20T03:00:00.000Z"
            },
            ...
            "testScript": {
                ...
                "type": "STEP_BY_STEP",
                "steps": [
                    {
                        "testData": "",
                        "customFieldValues": [
                            {
                                "booleanValue": true,
                                "id": 126265,
                                "customField": {
                                    "archived": false,
                                    "name": "checkbox - ts",
                                    "index": 0,
                                    "id": 38,
                                    "type": "CHECKBOX",
                                    "projectId": 10007,
                                    "required": false
                                }
                            }
                        ],
                    }
                ]
            },
        }
    ]

     

     

    Do you see a different response schema when trying this endpoint?

    • ihsb's avatar
      ihsb
      New Contributor

      Hi jfelix,

       

      Thanks for the response. It seems like I was using /rest/tests/1.0/ instead of the /rest/atm/1.0 endpoint. I'm assuming that one is for internal API calls. Not sure how I mixed them up.

       

      Thanks for your help.