gurock / trcli

TR CLI (trcli) is a command line tool for interacting with TestRail.
Mozilla Public License 2.0
48 stars 39 forks source link

Problems while adding a TestRail result with an attachment #202

Closed cmcclenaghan closed 4 months ago

cmcclenaghan commented 5 months ago

TestRail CLI Version

v1.7.0

CLI Environment

Windows 10, WSL Ubuntu 22.04, Python 3.10.12

TestRail Version

v7.0.2.1016

TestRail Instance Type

Professional Cloud

Current behavior

I have been trying to add an attachment to a TestRail result using trcli, the test run and test results are all created correctly in TestRail, but when trying to upload attachments I am receiving the following error.

{
    "error": "No file attached or upload size was exceeded."
}

My invocation of trcli is as follows

#! /usr/bin/env bash

trcli -n \
    -h https://----/testrail \
    --project "M----y" \
    --username cmc----om \
    --key $TEST_RAIL_API_TOKEN \
    --verbose \
    parse_junit \
    --case-matcher "name" \
    --title "----" \
    --run-description "CLI results test 001" \
    --file "test_rail_junit.xml" \
    --suite-name "Master"

This is a snippet of my junit file

            <testcase name="C10....op" classname="RCD" time="15975.5312381">
                <properties>
                    <property name="testrail_attachment" value="/c/test.html"></property>
                </properties>
            </testcase>

Running the trcli tool with --verbose shows me all the API calls including the failing attachment API call.

**** API Call
method: POST
url: https://----/testrail/index.php?/api/v2/add_attachment_to_result/207425
response status code: 400
response body: {'error': 'No file attached or upload size was exceeded.'}
****
Submitted 1 test results in 7.2 secs.

If I confirm this last call in Postman, I get the same error.

Desired behavior

The API response would be OK and the attachment would appear in the test result

More Details

No response

bitcoder commented 4 months ago
  1. What is the size of that attachment you're trying to upload?
  2. what is the absolute path of that attachment? It seems you're providing a absolute path, point to /c folder stored at root... is that correct?
cmcclenaghan commented 4 months ago

Hi. Thanks for the response

The attachment is only ~6MB, and I've tried with a nearly-empty file as well.

The file is located at the root of C:\, which is mapped by WSL as /c. Again, I've tried various locations and with absolute and relative paths in the JUnit file.

As I say, Postman (on Windows) is also giving me the same error response when I browse directly to the file.

bitcoder commented 4 months ago

thanks @cmcclenaghan , if you get the same error if you try to upload it directly to TR using the API, then the problem is on the API somehow. In this case, I would advise you to reach out TR support team providing an example of the API call you're doing and the error you're obtaining

cmcclenaghan commented 4 months ago

Fair enough. I have raised this as an API support request