Attaching evidence to a test execution API POST

Scott Maitland November 28, 2019

Hi,

Scenario:

I am using Java + TM4J REST API to do a GET request on a test cycle, and test all the test cases that live within that cycle, before then doing a test execution POST to return the results of the tests when they are complete. As part of this, my program captures a screenshot of the browser at point of test failure and stores this locally within the project as a PNG image. All works so far..

Issue:

If you run a test execution through the GUI, you can copy and paste an image in or use the upload file to attach the image.

I cannot seem to work out however, or find any resource on how to use Java to attach an image or to paste in the image as part of the test steps or comments of that test execution. There is no API endpoints (checked with Adaptivist themselves on that) but there must be some way of getting around this problem by passing the image along with the api POST as part of the JSON body. 

 

Thankful for any help regarding this.

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Deleted user January 7, 2020

TM4J Server API (v1) now has methods to post attachments to test executions and steps within them.

As per the API specification, in order to attach a file to a test execution (which corresponds to clicking on "Drop files here or select files" in TM4J web GUI on an open execution) use a POST call to the following resource: /testresult/{testResultId}/attachments

Mind that the testResultId part is not a test execution key, but the ID returned by the API when creating a test execution with the appropriate call.

The attachment must be passed as a multipart/form-data media type. E.g.:

POST https://jira.server.local/rest/atm/1.0/testresult/65208/attachments HTTP/1.1
Accept-Encoding: gzip,deflate
User-Agent: PostmanRuntime/7.15.0
Content-Type: multipart/form-data; boundary="----=_Part_5_1594638400.9687465465446"
MIME-Version: 1.0
Authorization: Basic PWhgKJHGKjhgkJHGKJHGUYT
Content-Length: 5766
Host: jira.server.local
Connection: Keep-Alive


------=_Part_5_1594638400.9687465465446
Content-Type: application/octet-stream; name=error.log
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="file"; filename="error.log"

<FILE CONTENT>

Scott Maitland January 31, 2020

Is this the same when using TM4J for cloud? That is what I am currently using.

Deleted user February 1, 2020

I haven't worked with TM4J Cloud API, but judging by the documentation, unfortunately no methods are implemented to work with attachments: https://docs.adaptavist.io/tm4j/cloud/api/v2/#operation/listTestCases.

It has just appeared in TM4J Server and let's hope they're working to add it in the Cloud ))

QIP Shot - Screen 01.02.20 11-34-39.png

Scott Maitland March 6, 2020

Fingers crossed, thanks for server side info :)

denisab85 February 16, 2022

@Scott Maitland, the create attachment request is finally implemented in Zephyr Cloud. Please take a look here: Create Attachment

Rasim Avcı March 8, 2022

I could not get it work, somebody can help me ?

 

Infact I realy wonder why testrun/testcase is not have a attachments ??

I use below to update test result in a cycle 

/testrun/{testRunKey}/testcase/{testCaseKey}/testresult

However this form does not have attachment.

And creating testresult id says it doesnt deal with a testrun, then how will I attach a file to test in a cycle then ????

 

In fact I tried every attachtment in this API but none of them worked for me

Zephyr Scale Server API (v1) (smartbear.com)

Rasim Avcı March 9, 2022

I can upload a file to test case, test cycle (test run), testresult that I have created but not a test instance in a cycle

TAGS
AUG Leaders

Atlassian Community Events