我是使用nodejs的新手,并且遇到了这个看似微不足道的问题,下面粘贴的节点JS代码为我要进行的POST调用提供了400:
jsonObjectJira = JSON.stringify({
"XXXXXX": {
"id": "XXX"
}
});
console.log(jsonObjectJira);
//prepare the header for the JIRA request
var postheadersjira = {
'authorization' : 'XXXXXX',
'cache-control' : 'no-cache',
'content-type' : 'application/json',
};
//the post options
var optionspostjira = {
host : 'XX.XXX.XX.XXX',
port : XXXX,
path : 'rest/api/2/issue/XXXXX/transitions',
method : 'POST',
headers : postheadersjira
};
//do the PUT call
var reqPostJira = http.request(optionspostjira, function(resjira) {
console.log("statusCode: ", resjira.statusCode);
// uncomment it for header details
console.log("headers: ", resjira.headers);
resjira.on('data', function(d1) {
console.info('PUT result:\n');
process.stdout.write(d1);
console.info('\n\PUT completed via NodeJS');
});
});
console.log("JSON: ", jsonObjectJira);
//write the json data
reqPostJira.write(jsonObjectJira);
reqPostJira.end();
reqPostJira.on('error', function(e) {
console.error(e);
});
})
enter code here
从具有相同标头的POSTMAN进行的相同调用可以正常工作。这里有明显的问题吗?