We have below curl commands which run perfect.
curl -x http://x.x.x.x:9999 -X POST -F token=aaa -F "ref=prod_call" -F variables[name]="No" -F variables[CR_Number]="" -F variables[HOSTS_FILE]="lil.ini" https://gitlab.com/api/v4/projects/1111/trigger/pipeline
Now same thing I implemented in node js and unfortunately it is not working
function callPipeline(){
console.log("The host we are going to execute here")
console.log("The command are going to execute here")
var formdata = new FormData();
formdata.append("token", "aaa");
formdata.append("ref", "prod_call");
formdata.append("variables[name]", "No");
formdata.append("variables[CR_Number]", "");
formdata.append("variables[HOSTS_FILE]", "lil.ini");
var options = {
method: 'POST',
host: "x.x.x.x", //proxy server
port: 9999,
path: "https://gitlab.com/api/v4/projects/1111/trigger/pipeline",
body: formdata,
};
return new Promise((resolve, reject) => {
http.request(options, function(res, err) {
console.log(res);
console.log(err);
//res.pipe(process.stdout);
resolve(res.toString() + "---err---" +err.toString())
});
})
}
Getting error
node:events:498
throw er; // Unhandled 'error' event
^
Error: socket hang up
at connResetException (node:internal/errors:691:14)
at Socket.socketOnEnd (node:_http_client:466:23)
at Socket.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1346:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ClientRequest instance at:
at Socket.socketOnEnd (node:_http_client:466:9)
at Socket.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1346:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ECONNRESET'
}