Create the Map
...
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:
...
Public Document Reference: - https://zephyrenterprisev3.docs.apiary.io/#reference/fieldmap/create-field-map/create-field-map
End Point: - /flex/services/rest/v3latest/fieldmap
Sample request
Code Block |
---|
{
"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
Code Block |
---|
{
"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}/
Method: - POST
Add The New Job
...
Import Job via Excel (Only xlsx format Supported)
Public Document Reference: - https://zephyrenterprisev3.docs.apiary.io/#reference/import/add-new-import-job/add-new-import-job
Method: - POST
End Point: - /flex/services/rest/v3/importSample request/
Request Body: -
Code Block | |
---|---|
json | { "name": "Job1Job_Name", "scheduledDate": 15959341987081694672045629, "folder":"/home/zephyr/zephyr/nodedata/temp/%2F1595939009589_0%2F20testcase "tc_import_utf8_DO_NOT_DELETE.xlsx", "fileExtension": ".xls", "fieldMapId": 14, "releaseId": 1, "importEntityType": "testcase", "status": "11000", "isUpload": falsetrue } |
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
...
Request Response: -
Code Block |
---|
{ "id": 41, "name": "Job1Job_Name ", "folder": "/home/zephyr/zephyr/nodedata/temp/%2F1595939009589_0%2F20testcasetc_import_utf8_DO_NOT_DELETE.xlsx", "fileExtension": ".xls", "scheduledDate": 15959341987081694672045629, "status": "11000", "fieldMap": { "id": 14, "name": "Map1Map", "description": "", "creationDate": 15958332000001694588400000, "projectId": 31, "startingRowNumber": 2, "discriminator": "byidchangebytestcasenamechange", "fieldMapDetails": [ { "zephyrField": "1", "mappedField": "EB" }, { "zephyrField": "2", "mappedField": "GD" }, { "zephyrField": "21", "mappedField": "DA" }, { "zephyrField": "3", "mappedField": "IF" }, { "zephyrField": "22", "mappedField": "HE" } ], "fieldMapEntityType": "testcase" }, "fieldMapId": 4, "releaseId": 1, "importEntityType": "testcase", "isUpload": falsetrue } |
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:
...
Upload the Excel file
Public Document Reference: - Add an Attachment
Method: - POST
End Point: - /flex/upload/document/genericattachment
Send a POST request to the following URL:
http://{ZEPHYR-SERVER}?jobid= {JobID from the above API}
Example: - /flex/upload/document/genericattachment
Sample response
Code Block |
---|
[
{
"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 ?jobid=1
In Body select the form-data and add
Key name: - import and select the type as a file.
Key value adds the attachment.
See the below Example: -
Execute import job by id
Public Document Reference :- https://zephyrenterprisev3.docs.apiary.io/#reference/import/execute-import-job-by-id/execute-import-job-by-id
Method :- PUT
End Point: - /flex/services/rest/v3/import/execute/{idJobID}/{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}
Example: - /flex/services/rest/v3/import/execute/1/run
Body: -
Code Block |
---|
{ "id |
...
Sample request
Code Block | ||
---|---|---|
| ||
": {JobID},
"action": "run"
} |
Example Body: -
Code Block |
---|
{ "id": 51, "action": "run" } |