Add an Attachment
Starting October 11, 2024 (Zephyr Enterprise 8.2), the Zephyr Enterprise documentation moved from its current location on Atlassian to a dedicated, standalone Zephyr Enterprise documentation page. Please see: https://support.smartbear.com/zephyr-enterprise/docs/en/migrating-to-zephyr-enterprise/via-rest-api/add-an-attachment.html
Summary
To add an attachment, perform the following steps:
1. Upload the file you want to attach to the server as a multi-request to /flex/upload/document/genericattachment
. Use a cURL command or Postman.
2. You will get the file name and temporary location in the JSON format.
3. Call the createAttachment API (/flex/services/rest/latest/attachment/list). Enter the name and temporary location of the uploaded file.
4. Your file is added as an attachment. Click Attachments to know more about the supported file formats.
Steps to perform
Upload the file to server using a cURL command
Upload the file to server via Postman
Attach the uploaded file
To Upload the file to the server using a cURL command:
1. Download cURL. Extract the zip file.
2. Open the command prompt. Navigate to the src folder containing the curl.exe executable.
3. Run the following cURL command:
curl --request POST \
--url '<https://<IP>/flex/upload/document/genericattachment'> \
--header 'Authorization: Bearer <ZEPHYR_API_TOKEN>' \
--header 'content-type: multipart/form-data'\
--form 'data=@<file path>'
<file path> - the location of the file you want to upload
<IP> - the server IP
<ZEPHYR_API_TOKEN> - your zephyr API token
Example: curl --request POST \
--url 'https://qademo.yourzephyr.com/flex/upload/document/genericattachment' \
--header 'Authorization: Bearer 23a579b6ad61afd7e9cf4c56c006adfbb2af30c3' \
--header 'content-type: multipart/form-data'\
--form 'data=@/Users/john.smith/pdfFile.pdf'
4. The above-mentioned command returns the temporary location of the uploaded file in the JSON format.
Example: file":"/opt/zephyr/nodedata/temp/1486648889167_29/js1.pdf"
To upload the file to the server via Postman:
Launch Postman.
Method : POST
URI :Â http://<server-ip>/flex/upload/document/genericattachment
(Example:Â https://qademo.yourzephyr.com/flex/ upload/document/genericattachment)On the Body tab, select form-data.
Specify key as data and for the value select file from the dropdown and choose the file you want to upload.
Do not provide any headers.
4. In the Authorization tab provide the Bearer token.
5. When you click SEND, you get the location of the uploaded file in the JSON format.
To attach the uploaded file:
1. In the createAttachment
API request provide the file path in the tempPath
attribute and send a request.
Method : POST
URI :Â http://<server-ip>/flex/services/rest/latest/attachment/list
[{
"name": "js1.pdf",
"itemId": 553,
"itemType": "testcase",
"contentType": "application/octet-stream",
"tempPath": "%2F1522663583732_106%2Fjs1.pdf"
}] |
On success (HTTP/1.1 200 OK) the file is attached.
Starting Release 8.2, Zephyr Enterprise documentation is moving from its current location on Atlassian to a dedicated, standalone Zephyr Enterprise Documentation page. https://support.smartbear.com/zephyr-enterprise/docs/en/welcome-to-zephyr-enterprise.html