Forum Discussion

bharath-vz7's avatar
bharath-vz7
New Contributor
4 years ago

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/j...
  • bharath-vz7's avatar
    4 years ago

    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.