When I get mycompany.testrail.io/index.php?/api/v2/get_cases/39 in browser I do get a json response with all the needed detail.
When I give the same in terminal with curl (not very knowledgeable in curl) I get:
`>> curl mycompany.testrail.io/index.php?/api/v2/get_cases/39
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
</body>
</html>`
and in browser I am getting all the response.
I suspect this has to do something with authorization:
const TestRail = require('testrail-api');
const config = require('../../cucumber/support/config.json');
const testRail = new TestRail({
host: config.testRail.host,
user: config.testRail.user,
password: config.testRail.apiKey
});
function getAlltestCases(projectid){
testRail.getCases(projectid,function (err, response, cases) {
console.log(response);
console.log(err);
console.log(cases);
});
}
module.exports = getAlltestCases;
where the config files do contain my testrailapikey generated in testrail with name supertest -(suspicious!? Because. My newman code only successed after creating the key as 'Newman')
in the format
`username - mytestrail@email.com
apikey -mysecretapikeyfromtestrail.io
my domain - mycompany.testrail.io`
and step definition as
...
Then('get all test cases', function () {
const projectid = 39
console.log("this worked?")
getAlltestCases(projectid);
});
called in BDD as
...
Then get all test cases
... And when call the npm run test
I am getting this in console.
You have a malformed URL in TestRail object, add https://
in the beginning to fix it