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

Feature Request: Upload attachment to test result in mini API


#1

Hi guys,

As was the case with my last post, I have another enhancement request for the mini API to use with our test automation framework.

We would like to be able to leverage the ability that exists in the standard interface to add file attachments to test results. We realize this is not as straightforward a feature to port over to the mini API as others for the simple fact that there is no active user with an authenticated connection to their local filesystem involved. We’re open to any suggestions you guys may have to make things simple within the confines of the current system and without sacrificing security. For instance, having us make the desired attachment accessible via an FTP or HTTP location on the TestRail server’s network and providing a URL to the API or something along those lines works for us.

I’m just spitballing… If you guys have other ideas that would be easier or a better fit in your opinion, I’m sure we could make it work on our end.

Thanks,

Costa


#2

Hi Costa,

Thanks for your request and feedback. We’ve received the request to support attachments via the API before and it’s already on our feature request list. We want to look into this eventually as we understand that this would be an useful enhancement to the API. This is not scheduled for a specific release so I don’t have a timeframe for this at the moment unfortunately.

In the meantime you could simply include links to the files in the result or case description fields. TestRail’s Markdown formatting allows you to include links to a separate HTTP server or directory for example so you could upload any files separately and include a link to this file in the description.

When we add attachment support to the API we will likely use the standard HTTP mechanisms to upload and download the files.

I hope this helps.

Thanks,
Dennis


#3

Is there any status on this? I would like to see this request implemented too <(^_^)>

Cheers,
Adron


#4

Hello Adron,

That’s not yet supported but it’s still on our list of things to look into. The API is constantly being improved and attachment support will be added eventually as well.

I hope this helps and please let me know in case you have any further questions or feedback.

Regards,
Tobias


#5

I vote for this feature too!
any status update here? uploading attachments via the mini api would be great!


#6

Hello David,

Thanks for your posting. The next version of TestRail will come with a new API and while attachments won’t be supported with the initial version it is planned to add this to the new API and we would like to look into this for one of the versions after the next one (3.0).

Regards,
Tobias


#7

+1 vote for this feature


#8

Thanks for your feedback, Blestka!

Regards,
Tobias


#9

any update regarding this feature request ?


#10

Hello Raji,

Thanks for your posting. The new and improved API has now been available for a while:

http://docs.gurock.com/testrail-api2/start

Attachment support is not yet part of the API but will most likely be added as part of the next larger API update.

Regards,
Tobias


#11

I also vote for that feature!
We using TestRail for System testing and UAT, for UAT users it’s very handy to raise issue within TestRail and not need to go to JIRA, but it would be great to have functionality to also add screenshots in the same time as it would save additional time to reconcile and devs/test to understand what the defect was about.


#12

I added your vote to this request, thanks for your feedback on this!

Regards,
Tobias


#13

Yet another vote for this feature from me. It would allow us to integrate our automated testing more completely into our existing process.


#14

Added to the list as well, thanks!

Regards,
Tobias


#15

+1 from us too.

We will likely add a workaround soon to push a base64 encoded file to a different directory on the web server, which would return a link in the appropriate markdown syntax (we will be adding screenshots to our test results where appropriate).


#16

Added to the list, thanks, Glenn.

Uploading the image elsewhere and then simply including a link/embedding the image is also our recommended workaround for this currently.

Regards,
Tobias


#17

Just on this - I have nearly finished adding support to upload images on the API side, but I’m wondering if there is a model for adding entries to the attachments table?

i.e. in the miniapi, there is the following code:

$this->load->model('milestone');

...
...
...

$id = $this->milestone_model->insert(
    $project->id,
    GI_MINIAPI_USER_ID,
    $arguments['name'],
    $arguments['description'],
    $arguments['due_on'],
    false,
    null
);

If there was a similar model I could access to be able to add attachment entries it would make my life much easier - then I can use the proper attachment viewmodel url:

Then I would not have to add another virtual host to serve the contents of another folder for these images I am adding and opening ourselves up to potential security issues.

Note that I do not wish to associate this with a Test Case or a Test Result (I want the image displayed inline and can do this via markdown), not sure if that’s a problem.


#18

Hello Glenn,

Thanks for the update. Modifying the API code is not supported and please do not change anything in the miniapi.php files or write directly to the database. This can lead to inconsistencies in the database and we cannot support such a modified database unfortunately. We recommend uploading screenshots or attachments to an external location and referencing/embedding those screenshots/attachments with links as a workaround in the meantime.

Regards,
Tobias


#19

Hi Tobias,

Since when has modifying the mini api been unsupported? We have been told previously by gurock that modifications to the miniapi files (for read only queries or using the helper functions) were absolutely fine.

I was asking whether you had a model available to the miniapi that would be able to be used as a supported interface to add attachments.


#20

Hello Glenn,

Thanks for your reply. We can support read-only modifications but do not recommend this (as this makes it difficult to update to newer API versions) but using the models to make database changes wouldn’t be supported. The main reason for this is that the model functions may change across TestRail versions (and they do) and it wouldn’t really be safe to use them. We have different mini API versions depending on the TestRail version and this is mostly due to model and database changes:

http://docs.gurock.com/testrail-api/installation

The new/current v2 API wouldn’t be affected by this as this API is directly included with TestRail and always up to date.

Regards,
Tobias