我正在编写一个小的node.js 脚本,该脚本将运行多个命令,如果任何一个命令失败,它将报告 Mentis 上的问题。我正在使用以下代码来报告 mantis bugtracker 中的问题。 Mantis bug tracker 附带了一堆 SOAP api 来完成类似的事情。 http://www.mantisbt.org/bugs/api/soap/mantisconnect.php?wsdl#op.idp90022480
var soap = require('soap');
var url = 'http://localhost/mantisbt-1.2.19/api/soap/mantisconnect.php?wsdl';
var user = 'administrator';
var password = 'root';
var args = {
username: user,
password: password,
project: {
id: 1
},
category: 'General',
summary: 'Test summary',
description: 'test description'
};
soap.createClient(url, function(err, client) {
client.mc_issue_add(args, function(err1, result) {
if(err1)
console.log( err1 );
else
console.log('Issue successfully created');
});
});
但我收到以下错误日志:
<faultstring>Project \'\' does not exist.</faultstring>
我有一个 id 1 的项目,我可以使用 php 创建具有相同数据的问题。我的理解是项目 ID 没有正确发送。等效的php代码如下。
$c = new SoapClientDebug("http://localhost/mantisbt-1.2.19/api/soap/mantisconnect.php?wsdl", ['trace' => true]);
$username = 'administrator';
$password = 'root';
$issue = array (
'summary' => 'PHP test issue',
'description' => 'PHP test description',
'project'=> array(
'id'=>1
),
'category'=>'General',
);
$c->mc_issue_add($username, $password, $issue);
PHP 代码可以正常运行。
最佳答案
你的参数应该是这样的:
var args = {
username: user,
password: password,
issue: {
project: {
id: 1
},
category: 'General',
summary: 'Test summary',
description: 'test description'
}
};
关于node.js - 在 Mantis 中以编程方式创建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28956246/