Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
PDF file encoding when downloading from API

I have the following code which downloads a PDF file from Xero API into Zapier. The code works fine, but the PDF file is always blank white page. I have inspected the contents of the PDF file returned (in a text file) and the top characters are returned as diamond shaped question marks (special characters). See screenshot below.

I have also compared with a working PDF file and the diamond shaped question marks are displayed as È on the good file.

Here's my code:

const pdfURL = {
  url: 'https://api.xero.com/api.xro/2.0/Quotes/' + bundle.inputData.QuoteID,
  method: 'GET',
  headers: {
    'Accept': 'application/pdf',
    'Authorization': `Bearer ${bundle.authData.access_token}`,
    'Xero-tenant-id': bundle.inputData.TenantID,
    'Content-type': 'application/pdf'
  }
};
const fileRequest = await z.request(pdfURL);
const url = await z.stashFile(fileRequest, fileRequest.length, 'Quote #123' + '.pdf', 'application/pdf;'); // knownLength and filename will be sniffed from the request. contentType will be binary/octet-stream
return {url};

Here's a screenshot of the contents in the corrupt PDF file:

enter image description here

Does anyone know what the problem could be?

I have tried setting the charset to 'utf-8' to no avail.

Any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I just had the exactly same problem here.

To solve it, just set the parameter raw:true in the z.request(), it will avoid parsing and messing up with the encoding.

Like that:

const pdfURL = {
  ...
  raw: true
};

Your file will then render properly.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda