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

482
Vistas
Uploading a file via API in Playwright (Typescript)

What: Testing the upload of a file (image) via API using Playwright

In the API Docs, for the request it states:

REQUEST BODY SCHEMA:

multipart/form-data

file (string )

A file to upload. The file should follow the specifications of RFC 2388 (which defines file transfers for the multipart/form-data protocol).

My Code:

test("POST: Upload or Create a file", async ({ request, baseURL }) => {
    const response = await request.post(baseURL + "/v2/files", {
      headers: {
        Accept: "*/*",
        ContentType: "multipart/form-data",
        account: AccountID,
        Authorization: bearer,
      },
      multipart: {
        file: "../../lib/logo.png",
        purpose: "logo",
      },
    });

    const body = JSON.parse(await response.text());
    console.log("this is the status:" + body.status);
    expect(response.status()).toBe(201);

Instead of a 201 status, I receive a 400. Also in debug mode in VS Code, I see:

[ "file should not be null or undefined", ]

Which leads me to believe the file is not being sent or sent incorrectly.

I'm not sure how to structure the file key within multipart, thoughts?

about 4 years ago · Juan Pablo Isaza
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