Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Attaching evidence to a test execution API POST

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

1 vote
Answer accepted

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>

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

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

Fingers crossed, thanks for server side info :)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

62 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you