With v1.18 we’ve introduced new easy-to-use endpoints for uploading attachments to test cases and test case results:
As these endpoints are more comfortable to upload attachments, the mapping endpoint for blob:comment is now deprecated and will be removed with v1.19.0.
Here’s a detailed guide to update to the new API endpoints.
Until now, uploading attachments required the following calls:
1. Create the blob
(POST /api/v1/blob)
2. Create a comment (the comment text references the blob)
(POST to /api/v1/comment/bulk)
3. Add the blob to the comment
(POST to /api/v1/blob/mapping/bulk/blob:comment?op=add)
4. Add the comment to the testcase or testrun-testcase
(POST to /api/v1/comment/mapping/bulk/comment:testcase?op=add
or /api/v1/comment/mapping/bulk/comment:testcase:testrun?op=add)
Please replace these calls with one single call to the new endpoints:
-
For adding attachments to test cases (see example in docs):
POST /api/v1/testcase/upload-attachment/:id
-
For adding attachments to test cases in runs (see example in docs):
POST /api/v1/testrun/upload-attachment/:tr-id/:tc-id
Example in docs does leave some room for improvement for this to work. I’m trying to get this to work for test results.
The format of the body is not explained properly and I’m failing to get images to actually render, they just show as 0b but the metadata is there.
Setting query params for title, filename and mime_type (I would much prefer this to be part of the body tbh).
I have tried sending the following without success:
- image data as plain string → Bad Request)
- image data in json {“data”: “image_data_string”} → Successful request but image has 0 bytes in the test run.
- send exactly the same info in the body as the old “create blob” endpoint accessed → Successful request but image has 0 bytes in the test run.
Whatever body: raw (image/file) data
is supposed to mean is not clear.
Thanks for your feedback, we will try to make the API clearer!
The body is the raw attachment data, i.e. the binary data from the image/file - that’s also why the meta data (title, filename, mime_type) can only be specified by query params, since the body is already used for the binary payload.
How the binary payload is specified depends on the language/tool you use, e.g.:
- for curl use the
-T path/to/file
argument
- for Python set the
data
argument for the request to bytes or a file-like object
Best regards,
Alex
I was missing a proper header for it to work correctly (in python using aiohttp).
headers={“Content-Type”: “application/octet-stream”}
Now working for me, thanks.
1 Like