I have a middleware server build with nodejs. I use it to communicate with different APIs. One of the endpoints is to get a pdf file that comes in binary format like
%PDF-1.4
%����
1 0 obj
<<
/CreationDate(D:20240703084315+00’00’
It was all good until I had to upgrade nodejs from v16 to v22+. After this I start receiving errors like
AxiosError: Request failed with status code 500
code: ‘ERR_BAD_RESPONSE’,
I did not changed anything about the request and the response, just upgraded to node v22
here is the request
const options = {
url: url,
method: 'POST',
responseType: 'arraybuffer',
data: bodyData,
headers: {
'Content-Type': 'application/json'
}
}
await axios(options)
Executing the request for the pdf in postman works fine. If the nodejs version is v16 is working fine, but with the latest – it fails. What I’m doing wrong?
I have tried all suggestions found on internet but without any success. I’m out of ideas and options so any help will be highly appreciated.