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

Add Results failed: Invalid array argument in URI


I’m using Node-Testrail. I am trying to submit results to a test run that was created as a test plan entry. My results look like this:

var testRailResults = { 
    results: [ 
     { test_id: 'C265668',
       status_id: 1,
       comment: 'This test case passed successfully.' },
     { test_id: 'C1363552',
       status_id: 1,
       comment: 'This test case passed successfully.' },
     { test_id: 'C4363451',
       status_id: 1,
       comment: 'This test case passed successfully.' } 
] };

And I’m using the API like this:

testrail.addResults("3422", testRailResults, function(body) {

Running it gives me this error:

TypeError: callback is not a function

After a little digging, I found this error from the server:

{"error":"Invalid array argument in URI: \/api\/v2\/add_results\/3422{\"results\":"}

I found these two functions in lib/testrail.js that handle the request:

TestRail.prototype.addResults = function(run_id, results, callback) {
      return this.addExtraCommand("add_results/", run_id, JSON.stringify(results), callback);

TestRail.prototype.addExtraCommand = function(command, id, extra, postData, callback) {
        uri: this.getFullHostName() + command + id + extra,
        headers: {
          "content-type": "application/json"
        body: postData
      }, function(err, res, body) {
        return callback(body);
      }).auth(this.user, this.password, true);

I have no idea why this is failing. Can someone help me out?


One, I believe the test IDs are incorrect. If you go to a test run, then click on a test you should see something like this at the top:


To add a result to that test via the API you would use 19639 for the test ID.

I haven’t used that wrapper before, so I don’t know if there are any other issues.


Thank you for the reply. However I tried using an open test and am still getting the same error.


You mention an ‘open’ test but donalaya noted that the IDs look to be the issue not that the Plan was ‘open’ or not…

You are not passing the original test case but passing a copy of the original case. The Ids in the tables are not alphanumeric - they are straight numbers. The R, T, and C are added by the interface for the appropriate screen.

So did you go into the Plan and refer to the correct Tests (without adding the “T”)?


Sorry, yes, I removed the 'T’s from the test IDs. Still no luck.

What should the URI look like for this request? The script is sending something like this:{"results":[{"test_id":"6080231","status_id":1,"comment":"this was a test"}]}

Is it supposed to be something like this?


Update: it looks like the node-testrail library I am using just has a bug. Was this made by a third party or is this an official TestRail product?


If it was a Gurock product it would available on the Gurock page. It looks like it is a wrapper made by a 3rd party to access the Gurock provided API.

"Is it supposed to be something like this?"

I believe the above is correct.


Hi Kristian,

Thanks for your post! We don’t have any experience with this third party wrapper, and we generally wouldn’t be able to assist with troubleshooting any bugs/issues with the script itself as part of our support. We’re happy to help with any errors you receive though if it’s part of the standard TestRail API syntax. The URI would look as follows in your example:

Note, you wouldn't include the colon (:) or any prefix such as 'T' or 'C' in front of any entity ID in an API request

So if you can update the wrapper/script to provide the correct format then this might resolve the issue, although there may be other issues as well. You can also look into any of the API bindings/wrappers that we provide for accessing TestRail’s API in case this might be more helpful:

Hope this helps!



The cause for this error was the npm package was outdated and had bugs. I switched to a newer, more supported package and everything works with ease. Thank you everyone who helped!


Hi Kristian,

Thanks for the update, and glad you were able to find one that works better! Just let us know in case you have any further questions.