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

add_result API method via node only works if routed through fiddler



I’m trying to use the TestRail API to write some methods in node.js in order to post test results to TestRail (to incorporate into the automated tests we’re developing). I can get add_result to post a result to my test if I cURL it, but not if I make the same request in node - I get a 500 Internal server error. I can make GET requests in node, but not POSTs. I figured I’d route the request through Fiddler to see what’s going on, and bizarrely the script began posting test results. I can’t figure out where I’m going wrong - is this a known issue?

Thanks in advance,



Here’s my node script if it helps

/*jslint node: true, sub: false, white: false */

var http = require(‘http’);

// do a test first!

// an object of options to indicate where to post to

var defaults = {
host: ‘devweb’,
port: 80,
path: ‘/testrail/index.php?/api/v2/add_result/62541’,
method: ‘POST’,
auth: ‘user:pass’,
headers: {
‘Content-Type’: ‘application/json’

// give it some data

var body = {
status_id : “1”

// Set up the request

var req = http.request(defaults, function (res) {
var data = “”;
res.on(‘data’, function (chunk) {
data += chunk;
console.log(‘I finished!’, data);

req.on(‘error’, function (e) {
“use strict”;
console.log('uh oh, that request was sketchy: ’ + e.message);

//write data to request body



Hello Carrie,

Thanks for your posting and we haven’t seen this behavior before. Do you use a self-hosted installation of TestRail? In this case, it would be great if you could send us the log files of your TestRail installation and/or web server for review. You can send this via email to The log directory is usually located in your TestRail installation directory (the exact path is configured in TestRail’s config.php).



Thanks for the speedy response. I looked through our logs this morning and it appears that the last one was added early February. I can’t find any reason for this. I’ll keep digging and try and find them.



Hello Carrie,

Thanks for the update. I would recommend enabling TestRail’s debug logging in this case:

If you could then retry the action and send us the log files afterwards for review, that would be great. Please send the logs to in this case (as ZIP/tar.gz, ideally).



Hi Tobias

To update on this: I used to rewrite my post request and it worked fine, so it looks as though this is an issue with the http.request library. I have enabled dubug logging and will email them if needed, but there is a workaround.




Thanks for the update, Carrie, that’s appreciated.



I am getting the same behaviour with the hosted version of TestRail using NodeJS. It seems to be down to the way the library treats the body of the request.

I’m also using the node HTTP library and just doing req.write(JSON.stringify(bodyAsJSObject).

Any ideas?

[UPDATE] I just moved to using the Request module, and again all is fine. We do a number of API calls using the vanilla HTTP/S libraries with node and they all seem to work fine. Very strange.


Hello Oliver,

Thanks for your feedback on this and good to hear that you’ve already found a workaround. Which response code did you get back from TestRail (e.g., 400)?