azure-devopsazure-pipelinesazure-devops-rest-api

ADO API for 'Add test cases to a suite with specified configurations' throws count value 0 with value []


This is the JSON Payload :

{
"pointAssignments": [
  {
    "configurationId": 2738
  }
],
"workItem": 3931630
}

The Response Code is '200 OK' but the response is :

{
"count": 0,
"value": []
}

https://learn.microsoft.com/en-us/rest/api/azure/devops/testplan/suite-test-case/add?view=azure-devops-rest-7.1

I'm not sure why this is not working. Any suggestions ?

I was expecting the WorkItem (Test Case) to be added to the Suite with the Configuration ID mentioned in the JSON Payload.

https://dev.azure.com/{xx}/{yy}/_apis/testplan/Plans/2781987/suites/3681479/TestCase?api-version=7.0


Solution

  • The JSON Payload you pass to the API request is not correct. For your case, the correct JSON Payload is below.

    [
        {
            "pointAssignments": [
                {
                    "configurationId": 2738
                }
            ],
            "workItem": {
                "id": 3931630
            }
        }
    ]
    

    If you want to add multiple test cases with multiple configurations, the JSON Payload should look like the following sample.

    [
        {
            "pointAssignments": [
                {
                    "configurationId": 28
                },
                {
                    "configurationId": 29
                }
            ],
            "workItem": {
                "id": 112
            }
        },
        {
            "pointAssignments": [
                {
                    "configurationId": 28
                },
                {
                    "configurationId": 29
                }
            ],
            "workItem": {
                "id": 113
            }
        }
    ]