Import the Test Case

Map the fields

Use the following operation to map fields in Zephyr Enterprise:

POST /flex/services/rest/v3/fieldmap

Request format

To map fields, send a POST request to the following URL:

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

Sample request

{
  "name": "Map1",
  "description": "",
  "startingRowNumber": 2,
  "discriminator": "byidchange",
  "fieldMapDetails": [
    {
      "displayName": "Name *",
      "zephyrField": 1,
      "mappedField": "B",
      "mandatory": true
    },
    {
      "displayName": "Test Steps *",
      "zephyrField": 2,
      "mappedField": "D",
      "mandatory": true
    },
    {
      "displayName": "Expected Results *",
      "zephyrField": 3,
      "mappedField": "F",
      "mandatory": true
    },
    {
      "displayName": "Alt Id *",
      "zephyrField": 21,
      "mappedField": "A",
      "mandatory": true
    },
    {
      "displayName": "TestData",
      "zephyrField": 22,
      "mappedField": "E",
      "mandatory": false
    },
    {
      "displayName": "Priority",
      "zephyrField": 23,
      "mappedField": "G",
      "mandatory": false
    }
  ],
  "fieldMapEntityType": "testcase",
  "projectId": 1
}

startingRownumber - The number of the row in an Excel sheet where you will start mapping by using a discriminator. The following discriminators are available:

  • By ID change

  • By empty row

  • By test case name change

Sample response

{
  "id": 1,
  "name": "Map1",
  "description": "",
  "creationDate": 1595932827461,
  "projectId": 1,
  "startingRowNumber": 2,
  "discriminator": "byidchange",
  "fieldMapDetails": [
    {
      "zephyrField": "1",
      "mappedField": "B"
    },
    {
      "zephyrField": "2",
      "mappedField": "D"
    },
    {
      "zephyrField": "21",
      "mappedField": "A"
    },
    {
      "zephyrField": "3",
      "mappedField": "F"
    },
    {
      "zephyrField": "22",
      "mappedField": "E"
    },
    {
      "zephyrField": "23",
      "mappedField": "G"
    }
  ],
  "fieldMapEntityType": "testcase"
}

Create an import job

Use the following operation to create an import job in Zephyr Enterprise:

POST /flex/services/rest/v3/import

Request format

To create an import job, send a POST request to the following URL:

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

Sample request

{
  "name": "Job1",
  "scheduledDate": 1595934198708,
  "folder":"/home/zephyr/zephyr/nodedata/temp/%2F1595939009589_0%2F20testcase.xlsx",
  "fileExtension": ".xls",
  "fieldMapId": 1,
  "releaseId": 1,
  "importEntityType": "testcase",
  "status": "11000",
  "isUpload": false
}

folder - the folder where the file will be downloaded first. /home/zephyr/zephyr is the location of the Zephyr installation directory.

fieldMapId = The ID of the map containing the mapping details.

Sample response

{
    "id": 4,
    "name": "Job1",
    "folder": "/home/zephyr/zephyr/nodedata/temp/%2F1595939009589_0%2F20testcase.xlsx",
    "fileExtension": ".xls",
    "scheduledDate": 1595934198708,
    "status": "11000",
    "fieldMap": {
        "id": 1,
        "name": "Map1",
        "description": "",
        "creationDate": 1595833200000,
        "projectId": 3,
        "startingRowNumber": 2,
        "discriminator": "byidchange",
        "fieldMapDetails": [
            {
                "zephyrField": "1",
                "mappedField": "E"
            },
            {
                "zephyrField": "2",
                "mappedField": "G"
            },
            {
                "zephyrField": "21",
                "mappedField": "D"
            },
            {
                "zephyrField": "3",
                "mappedField": "I"
            },
            {
                "zephyrField": "22",
                "mappedField": "H"
            }
        ],
        "fieldMapEntityType": "testcase"
    },
    "releaseId": 1,
    "importEntityType": "testcase",
    "isUpload": false
}

Note

The first file needs to be uploaded by using the genericattachment call. You will get a tempFilePath in the response. This path needs to be used in the API above.

To call genericattachment, use the following operation:

POST /flex/upload/document/genericattachment

Send a POST request to the following URL:

http://{ZEPHYR-SERVER}/flex/upload/document/genericattachment

Sample response

[
  {
    "fileName": "20testcase.xlsx",
    "dateCreated": "null",
    "fieldName": "data",
    "tempFilePath": "%2F1595939009589_0%2F20testcase.xlsx",
    "description": "null",
    "contentType": "application/octet-stream"
  }
]

Run the import job

Use the following operation to run the import job:

PUT /flex/services/rest/v3/import/execute/{id}/{action}

{id} - the ID of the import job.

{action} - run.

Request format

To run the import job, send a PUT request to the following URL:

http://{ZEPHYR-SERVER}/flex/services/rest/v3/import/execute/{id}/{action}

Sample request

{
  "id": 5,
  "action": "run"
}

See Also

Migration REST API

Publication date: