Ask a Question

How to add an attachment to an execution under test cycle using zapi rest api

SOLVED
bharath-vz7
New Contributor

How to add an attachment to an execution under test cycle using zapi rest api

Hi,

 

How to add an attachment to an execution under test cycle using zapi rest api.

I intend to use python as a programming language.

I believe its by using this api->    http://localhost:2990/jira/rest/zapi/latest/attachment?entityId=&entityType=   

 

But how do I pass the attachment file or attachment file link(url) to this api?

 

Thanks.

1 REPLY 1
bharath-vz7
New Contributor

Found the solution:

 

Api is ->  /rest/zapi/latest/attachment?entityId=12345&entityType=Execution

 

entityId is executionId.

 

Send the file as form-data, you will see this option in postman.

Below is the Python code if needed.

import requests

url = "baseUrl/rest/zapi/latest/attachment?entityId=12345&entityType=Execution"

payload={}
files=[
  ('file',(filename,open('complete_file_path','rb'),'text/html'))
]
# File is html in this example. You can pass multiple files in the above list, just replicate.
# for header pass basic auth.

response = requests.request("POST", url, headers=headers, files=files)

 

Thanks.

cancel
Showing results for 
Search instead for 
Did you mean: