英文:
I am getting this Error: Invalid URI "mycompany.testrail.io/index.php?/api/v2/get_cases/39" when integrating with cucumber -supertest
问题
当我在浏览器中访问mycompany.testrail.io/index.php?/api/v2/get_cases/39时,我会收到包含所有所需详细信息的JSON响应。
当我在终端中使用curl(不太了解curl)输入相同的内容时,我收到以下响应:
`>> 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>`
在浏览器中我可以获得所有响应。
我怀疑这与授权有关:
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;
配置文件中包含了我的TestRail API密钥,该密钥在TestRail中以名称"supertest"生成(可疑吗?因为只有在我将密钥命名为"Newman"后,我的Newman代码才成功)。
格式如下:
`用户名 - mytestrail@email.com
API密钥 - mysecretapikeyfromtestrail.io
我的域名 - mycompany.testrail.io`
步骤定义如下:
...
Then('get all test cases', function () {
const projectid = 39
console.log("this worked?")
getAlltestCases(projectid);
});
在BDD中调用如下:
...
Then get all test cases
当运行npm run test
时,我在控制台上收到以下错误:
英文:
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.
答案1
得分: 1
你的TestRail对象中有一个格式不正确的URL,请在开头添加https://
以修复它。
英文:
You have a malformed URL in TestRail object, add https://
in the beginning to fix it
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论