Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
Socket Error while REST Call in via method POST not working

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'
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!