Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

How get Images to get_results using API?


#1

I am doing a vba macro to get Images of results and create a ppt file.

but when I try acess “index.php?/attachments/get/6175” using API is returned a text

how can I download this file?


#2

Hi Bruno,

There’s currently no direct API for downloading attachments via the API but would the print views be an option maybe? Just click on the printer icon when viewing a test and this would also render embedded screenshots.

Cheers,
Tobias


#3

Hi Tobias,

The button print not serve to me. because I am doing a way to drop imagens from site and send to Clients.

I try many ways to acess and login in the testRail.

For example.
If I change “/index.php?/api/v2/get_projects” for “/index.php?/attachments/get/6175” Is returned the Login page

There is a way download this images by code?

It is code that I am using to get projects for example.

Set oRequest = CreateObject(“WinHttp.WinHttpRequest.5.1”)

With oRequest
.Open “GET”, url_base + “/index.php?/api/v2/get_projects”, False
’.Open “GET”, url_base + “/index.php?/attachments/get/6175”, False
’.SetRequestHeader “Content-Type”, “text/html”
.SetRequestHeader “Content-Type”, "application/json"
auth = Base64Encode(user + “:” + pass)
.SetRequestHeader “Authorization”, "Basic " + auth
.Send
.WaitForResponse
sResult = .ResponseText
End With


Accessing Testrail API using VBA in Excel
#4

Hi Bruno,

One option is in fact to use index.php?attachments/get/###. This is not a regular API function (but part of the UI) so the API authentication wouldn’t work and you would need to submit the regular session cookie of an authenticated user session.

Cheers,
Tobias