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

Add_attachment_to_result: API returns login page

The following code ends up returning the TestRail login page instead of a useful error. I tested my credentials by successfully submitting a test result via the TestRailClient so it shouldn’t be an issue with my credentials…

base url is : “https://mycompany.testrail.io

76888 is a valid Result id.

            APIClient client = new APIClient(Constants.TestRailBaseUrl)
            {
                User = Constants.TestRailUserEmail,
                Password = Constants.TestRailPassword
            };

            JObject c = (JObject)client.SendPost($"add_attachment_to_result/76888", pofImagePath);

Suspect I just got turned around on what a Test is vs a Result. I don’t see any ResultIds in the UI so I’ll need to pull down a list of Results and pick one to use in the add_attachment_to_result call. I was trying to pass in the test id which is invalid. Assuming that is the issue, the error message could be improved.

Hope the value of multiple results per test is worth the confusion that it adds.

Yeah, that solved the issue. I am able to upload image attachments now. Just needed to specify the result id and not the test id.

1 Like