javaalmhp-quality-centerhp-alm

ALM create new Test Run using JSON payload ( REST API)


{
  "entities": [
    {
      "Type": "run",
      "Fields": [
        {
          "values": [
            {
              "value": "Run_10_07_2019_11_13_53_12345"
            }
          ],
          "Name": "name"
        },
        {
          "values": [
            {
              "value": "1"
            }
          ],
          "Name": "test-instance"
        },
        {
          "values": [
            {
              "value": "12345"
            }
          ],
          "Name": "testcycl-id"
        },
        {
          "values": [
            {
              "value": "56789"
            }
          ],
          "Name": "cycle-id"
        },
        {
          "values": [
            {
              "value": "23456"
            }
          ],
          "Name": "test-id"
        },
        {
          "values": [
            {
              "value": "hp.qc.test-instance.EXTERNAL"
            }
          ],
          "Name": "subtype-id"
        },
        {
          "values": [
            {
              "value": "Passed"
            }
          ],
          "Name": "status"
        },
        {
          "values": [
            {
              "value": "novice"
            }
          ],
          "Name": "owner"
        }
      ]
    }
  ]
}

Output { "Id": "qccore.general-error", "Title": "General Error", "ExceptionProperties": null, "StackTrace": null } 500 Internal server error

I am trying to create a test run using REST API for ALM EndPoint

POST /qcbin/rest/domains/{domain}/projects/{project}/runs
Content-Type: application/json
Accept: application/json
Cookie: QCSession=xxx; LWSSO_COOKIE_KEY=xxx

Can someone please help me out with this issue ?


Solution

  • Your request (method, headers, URL) looks correctly.

    But your data/JSON must not contain a "multi-entity" document (starting with "entities").

    Instead, change it to contain just 1 run entity as follows.

    {
       "Fields": [
          {
             "Name": "test-id",
             "values": [
                {
                   "value": "843"
                }
             ]
          },
          {
             "Name": "test-name",
             "values": [
                {
                   "value": "d1"
                }
             ]
          },
          {
             "Name": "has-linkage",
             "values": [
                {
                   "value": "N"
                }
             ]
          },
          {
             "Name": "path",
             "values": [
                {}
             ]
          },
          {
             "Name": "cycle-id",
             "values": [
                {
                   "value": "1"
                }
             ]
          },
          {
             "Name": "vc-version-number",
             "values": []
          },
          {
             "Name": "draft",
             "values": [
                {
                   "value": "N"
                }
             ]
          },
          {
             "Name": "host",
             "values": [
                {
                   "value": "WS-123456"
                }
             ]
          },
          {
             "Name": "id",
             "values": [
                {
                   "value": "1"
                }
             ]
          },
          {
             "Name": "state",
             "values": [
                {}
             ]
          },
          {
             "Name": "test-config-id",
             "values": [
                {
                   "value": "1234"
                }
             ]
          },
          {
             "Name": "ver-stamp",
             "values": [
                {
                   "value": "2"
                }
             ]
          },
          {
             "Name": "iters-params-values",
             "values": [
                {}
             ]
          },
          {
             "Name": "os-build",
             "values": [
                {
                   "value": "Build 123456"
                }
             ]
          },
          {
             "Name": "os-sp",
             "values": [
                {}
             ]
          },
          {
             "Name": "name",
             "values": [
                {
                   "value": "Run_11-25_9-51-41"
                }
             ]
          },
          {
             "Name": "testcycl-name",
             "values": [
                {
                   "value": "d1 [1]"
                }
             ]
          },
          {
             "Name": "status",
             "values": [
                {
                   "value": "Not Completed"
                }
             ]
          },
          {
             "Name": "os-config",
             "values": [
                {}
             ]
          },
          {
             "Name": "vc-locked-by",
             "values": [
                {}
             ]
          },
          {
             "Name": "bpt-structure",
             "values": [
                {}
             ]
          },
          {
             "Name": "cycle",
             "values": [
                {}
             ]
          },
          {
             "Name": "execution-date",
             "values": [
                {
                   "value": "2019-11-25"
                }
             ]
          },
          {
             "Name": "duration",
             "values": [
                {
                   "value": "4"
                }
             ]
          },
          {
             "Name": "last-modified",
             "values": [
                {
                   "value": "2019-11-25 09:51:46"
                }
             ]
          },
          {
             "Name": "subtype-id",
             "values": [
                {
                   "value": "hp.qc.run.MANUAL"
                }
             ]
          },
          {
             "Name": "attachment",
             "values": [
                {}
             ]
          },
          {
             "Name": "test-description",
             "values": [
                {}
             ]
          },
          {
             "Name": "assign-rcyc",
             "values": [
                {}
             ]
          },
          {
             "Name": "text-sync",
             "values": [
                {}
             ]
          },
          {
             "Name": "owner",
             "values": [
                {
                   "value": "john_doe"
                }
             ]
          },
          {
             "Name": "pinned-baseline",
             "values": [
                {}
             ]
          },
          {
             "Name": "comments",
             "values": [
                {}
             ]
          },
          {
             "Name": "iters-sum-status",
             "values": [
                {}
             ]
          },
          {
             "Name": "bpta-change-detected",
             "values": []
          },
          {
             "Name": "test-instance",
             "values": [
                {
                   "value": "1"
                }
             ]
          },
          {
             "Name": "cycle-name",
             "values": [
                {
                   "value": "ts"
                }
             ]
          },
          {
             "Name": "os-name",
             "values": [
                {
                   "value": "Windows 10"
                }
             ]
          },
          {
             "Name": "user-template-07",
             "values": []
          },
          {
             "Name": "environment",
             "values": [
                {}
             ]
          },
          {
             "Name": "vc-status",
             "values": [
                {}
             ]
          },
          {
             "Name": "execution-time",
             "values": [
                {
                   "value": "09:51:46"
                }
             ]
          },
          {
             "Name": "bpta-change-awareness",
             "values": [
                {}
             ]
          },
          {
             "Name": "user-template-01",
             "values": [
                {}
             ]
          },
          {
             "Name": "user-template-02",
             "values": [
                {}
             ]
          },
          {
             "Name": "user-template-03",
             "values": []
          },
          {
             "Name": "user-template-04",
             "values": [
                {}
             ]
          },
          {
             "Name": "user-template-05",
             "values": [
                {}
             ]
          },
          {
             "Name": "testcycl-id",
             "values": [
                {
                   "value": "1"
                }
             ]
          },
          {
             "Name": "user-template-06",
             "values": []
          }
       ],
       "Type": "run",
       "children-count": 0
    }
    

    (Just an example - you probably need to update field names and values to match your particular template).