Add an Attachment
Summary
To add an attachment, you need to perform the follonwig steps:
1. Upload the file you want to attach to the server as a multi-request to /flex/upload/document/genericattachment
via a cURL command or Postman.
2. The step above will return the file name and location in the JSON format.
3. Call the createAttachment API passing the name and location of the uploaded file.
4. On success, the file will be attached.
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 and navigate to the src folder containing the curl.exe executable.
3. Run the following cURL command:
curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@<file path>" http://<ip>/flex/upload/document/genericattachment
<file path> - the location of the file to be uploaded
<ip> - the server IP.
Example: curl -i -X POST -H "Content-Type: multipart/form-data" -F "data=@C:/Users/Praveenkumar/Downloads/js1.pdf"Â http://52.74.143.162/flex/upload/document/genericattachment
4. The above-mentioned command will return 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:
1. Download the Postman Chrome extension.
2. After adding the Postman extension, launch Postman.
Method : POST
URI :Â http://<server-ip>/flex/upload/document/genericattachment
 (Example: http://52.74.143.162/flex/upload/document/genericattachment)
3. On the Body tab, select form-data.
4. Specify key as data and for the value select file from the dropdown and choose the file to be uploaded.
Do not provide any headers.
5. Clicking on SEND will return 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 will be 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