Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

551
Visualizações
Node.js: ECONNRESET when making multipart/form-data post request?

I am getting the following error:

(node:12268) [https://github.com/node-fetch/node-fetch/issues/1167] DeprecationWarning: form-data doesn't follow the spec and requires special treatment. Use alternative package
(Use `node --trace-deprecation ...` to show where the warning was created)
FetchError: request to https://api.nordigen.com/v2/report failed, reason: socket hang up
    at ClientRequest.<anonymous> (file:///home/doejohn/www/work/johndoe/backend/Scripts/nordigen-scripts/node_modules/node-fetch/src/index.js:108:11)
    at ClientRequest.emit (node:events:539:35)
    at TLSSocket.socketCloseListener (node:_http_client:427:11)
    at TLSSocket.emit (node:events:539:35)
    at node:net:709:12
    at TCP.done (node:_tls_wrap:582:7) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET',
  erroredSysCall: undefined
}

When I do the following request:

  const data = new FormData();
  data.append("input", file);
  const init = {
    method: "POST",
    headers: {
      Authorization: `Bearer ${oauthToken}`,
    },
    body: data,
  };
  fetch("https://api.nordigen.com/v2/report", init)
    .then((res) => res.json())

I got it working perfectly with Python. But somehow when converting it to Node.js I seem to be doing something wrong.

resReport = requests.post("https://api.nordigen.com/v2/report", files={'input': open('test2.json', 'rb')}, headers={"Authorization": f"Bearer {token}"})

The file input at node.js and python are same file on disk. I also checked the auth token and it is correct.

The docs at the API have the following curl request as example:

curl -X POST \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-F input=@example.json \
https://api.nordigen.com/v2/report

How to solve this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Adding the following solved the issues.

data.append(
'input',
fs.createReadStream(`./data/transactions_${process.env.GEBRUIKER}.json`)
)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda