Create a Test Case Tree

Create a folder or phase

Use the following operation to create a folder or phase in Zephyr Enterprise:

POST /flex/services/rest/v3/testcasetree?parentid=0&assignedusers=

Request format

To create a folder or phase, send a POST request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/v3/testcasetree?parentid=0&assignedusers=

Request body

{
"name":"N4",
"description":"",
"type":"Phase",
"releaseId":1
}

releaseId - the ID of the release.

For information on creating a tree node, see Create Tree Node.

Response body

{
  "id": 17,
  "type": "Phase",
  "name": "N4",
  "description": "",
  "revision": 0,
  "categories": [],
  "assignedUsers": [1,2,3,5,6,7,8],
  "releaseId": 1,
  "linkedTCRCatalogTreeId": 0,
  "createdOn": 1588073471630,
  "createdBy": 1,
  "lastModifiedBy": 1,
  "lastModifiedOn": 1588073471641,
  "testcaseCount": 0,
  "cumulativeTestcaseCount": 0
}

Create a sub-folder or sub-phase

Use the following operation to create a sub-folder or sub-phase in Zephyr Enterprise:

POST /flex/services/rest/v3/testcasetree?parentid={ID of the parent folder}

Request format

To create a sub-folder or sub-phase, send a POST request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/v3/testcasetree?parentid={ID of the parent folder}

Request body

{
"name":"Sub Folder",
"description":"",
"type":"Module",
"releaseId":1
}

releaseId - the ID of the release.

parentid - the ID of the parent folder of the sub-folder you want to create.

For information on creating a tree node, see Create Tree Node.

Response body

{
  "parentId": 17,
  "id": 18,
  "type": "Module",
  "name": "N4 sub folder",
  "description": "",
  "revision": 0,
  "categories": [],
  "assignedUsers": [1,2,3,5,6,7,8],
  "releaseId": 1,
  "linkedTCRCatalogTreeId": 0,
  "createdOn": 1588073734061,
  "createdBy": 1,
  "lastModifiedBy": 1,
  "lastModifiedOn": 1588073734072,
  "testcaseCount": 0,
  "cumulativeTestcaseCount": 0
}

Create a test case

Use the following operation to create a test case in Zephyr Enterprise:

POST /flex/services/rest/latest/testcase/

Request format

To create a test case, send a POST request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/

Request body

{
  "tcrCatalogTreeId": 18,
        "testcase": {
                      "name": "Testcase in Sub-Folder"
                    }
}

tcrCatalogTreeId - the ID of the folder where you want to create the test case.

For more information on creating test cases, see Create Test Case.

Response body

{
    "id": 49,
    "tcrCatalogTreeId": 18,
    "revision": 0,
    "stateFlag": 0,
    "lastModifiedOn": 1588074263271,
    "versionNumber": 1,
    "createDatetime": 1588074263271,
    "createdById": 1,
    "modifiedById": 1,
    "testcase": {
        "customProperties": {},
        "customProcessedProperties": {},
        "id": 31,
        "name": "Testcase in Sub-Folder",
        "lastModifiedOn": 1588074263243,
        "creationDate": 1588057200000,
        "createDatetime": 1588074263271,
        "tcCreationDate": "04/28/2020",
        "creatorId": 1,
        "lastUpdaterId": 1,
        "automated": false,
        "customFieldProcessed": false,
        "customFieldValues": [],
        "testcaseSequence": {
            "seqNumber": 29
        },
        "testcaseId": 29,
        "versionNumber": 1,
        "projectId": 1,
        "testcaseType": "ORIGINAL",
        "requirementIds": [],
        "requirementIdsNew": [],
        "automatedDefault": false,
        "testcaseShared": false
    },

Add an attachment

Prerequisites

To attach a file to a test case, you need to upload it to the server. To do that:

1. Upload the file as a multi-request to /flex/upload/document/genericattachment via a cURL command or Postman. This will return the file name and location in the JSON format.

2. Call the createAttachment API passing the name and location of the uploaded file. On success, the file will be attached.

Attach the uploaded file

To attach the uploaded file to your test case, specify the file path you got upon uploading the file (see above) in the tempPath attribute of a createAttachment API request and send the request.

API operation

POST /flex/services/rest/latest/attachment/list

Request format

To attach an uploaded file to a test case, send a POST request to the following URL:

http://<server-ip>/flex/services/rest/latest/attachment/list

2193784954.png

Request body

[{
   "name": "js1.pdf",
   "itemId": 553,
   "itemType": "testcase",
   "contentType": "application/octet-stream",
   "tempPath": "%2F1522663583732_106%2Fjs1.pdf"
}]

tempPath - the path to the uploaded file.

On success (HTTP/1.1 200 OK), the file will be attached.

Update an existing test case (update the tag, priority, custom fields, etc.)

Use the following operation to update a test case in Zephyr Enterprise:

PUT /flex/services/rest/v3/testcase/{id}

Request format

To update a test case, send a PUT request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/v3/testcase/{id}

{id} - the ID of the entity you want to update.

Request body

{
  "id": 667,
  "testcase": {
    "customProperties": {
      "zcf_1003": "Text Value"
    },
    "customProcessedProperties": {},
    "id": 385,
    "name": "Untitled1",
    "priority":2,
    "estimatedTime": 600,
    "testcaseId": 373,
    "projectId": 1,
    "comments": "",
    "tags": [
      "Tag1",
      "tag2"
    ],
    "tagOptions": [],
    "tag": "Tag1 tag2"
  },
  "projectId": 1,
  "releaseId": 1
}

Response body

{
   "id": 667,
   "tcrCatalogTreeId": 20,
   "revision": 0,
   "stateFlag": 0,
   "lastModifiedOn": 1588075481270,
   "versionNumber": 1,
   "createDatetime": 1588075400249,
   "createdById": 9,
   "modifiedById": 1,
   "testcase":    {
      "customProperties": {"zcf_1003": "Text Value"},
      "customProcessedProperties": {},
      "id": 385,
      "name": "Untitled1",
      "description": "",
      "priority": "2",
      "tag": "Tag1 tag2",
      "lastModifiedOn": 1588075481270,
      "creationDate": 1588032000000,
      "createDatetime": 1588075400255,
      "tcCreationDate": "04/28/2020",
      "comments": "",
      "isComplex": false,
      "estimatedTime": 600,
      "writerId": 0,
      "creatorId": 9,
      "lastUpdaterId": 1,
      "oldId": 0,
      "automated": false,
      "customFieldProcessed": true,
      "customFieldValues": [      {
         "fieldId": 1003,
         "entityId": 373,
         "fieldName": "zcf_1003",
         "displayName": "Text1",
         "fieldTypeMetadata": 1,
         "textValue": "Text Value",
         "id": 31,
         "testcaseVersionId": 385,
         "createDatetime": 1588075481278,
         "modifiedDatetime": 1588075481278,
         "createdById": 1,
         "modifiedById": 1,
         "value": "Text Value"
      }],
      "testcaseSequence": {"seqNumber": 373},
      "testcaseId": 373,
      "versionNumber": 1,
      "projectId": 1,
      "testcaseType": "ORIGINAL",
      "requirementIds": [],
      "requirementIdsNew": [],
      "automatedDefault": false,
      "testcaseShared": false
   },
   "projectId": 1,
   "releaseId": 1,
   "isDerivedFromBDD": false,
   "orderId": 494,
   "maxVersionNumber": 1,
   "projectIdParam": 1,
   "original": true
}

Create a test step

Use the following operation to create a test step in Zephyr Enterprise:

POST /flex/services/rest/latest/testcase/{testcaseVersionId}/teststep/detail/{tctId}

Request format

To create a test step, send a POST request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/{testcaseVersionId}/teststep/detail/{tctId}

{testcaseVersionId} - the ID of the test case version.

tctId - test case ID in the test case tree.

Request body

{
  "tcId": 199,
  "maxId": 1,
  "step": {
    "step": "login to application",
    "data": "enter credentials",
    "result": "login successful",
    "orderId": 1
  },
    "tctId": 215
}

tcId - the test case ID.

maxId - the maximum number of steps.

orderId - the step order ID.

Response body

{
  "id" : 1,
  "tcId" : 199,
  "maxId" : 1,
  "steps" : [ ],
  "step" : {
    "customProperties" : { },
    "customProcessedProperties" : { },
    "id" : 1,
    "localId" : 1,
    "orderId" : 1,
    "step" : "login to application",
    "data" : "enter credentials",
    "result" : "login successful",
    "customFieldProcessed" : true,
    "customFieldValues" : [ ]
  },
  "maxVersionNumber" : 1,
  "testcaseVersionId" : 199,
  "releaseId" : 4,
  "projectId" : 1,
  "tctId" : 215
}

For more information on test step creation, see Create Test Step.

Update a test step

Use the following operation to update an existing test step in Zephyr Enterprise:

PUT /flex/services/rest/latest/testcase/{testcaseVersionId}/teststep/detail/{tctId}

Request format

To update an existing test step, send a PUT request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/latest/testcase/{testcaseVersionId}/teststep/detail/{tctId}

{testcaseVersionId} - the ID of the test case version.

tctId - test case ID in the test case tree.

Request body

{
  "id": 4,
  "tcId": 6,
  "maxId": 1,
  "steps": [],
  "step": {
    "customProperties": {},
    "customProcessedProperties": {},
    "id": 7,
    "localId": 1,
    "orderId": 1,
    "step": "login to application update",
    "data": "enter credentials update ",
    "result": "login successful update",
    "customFieldProcessed": true,
    "customFieldValues": []
  },
  "maxVersionNumber": 1,
  "testcaseVersionId": 6,
  "releaseId": 1,
  "projectId": 1,
  "tctId": 7
}

tcId - the test case ID.

maxId - the maximum number of steps.

orderId - the step order ID.

See Also

Migration REST API

Publication date: