(Created on )

Puppeteer: Collected request body data of type {value} is not supported

The BiDi request body collector encountered a data item type it cannot represent.


The BiDi request body collector encountered a data item type it cannot represent.

Error message

Collected request body data of type {value} is not supported

{value} is replaced by the value shown in your error message.

How this error happens

BiDi request-body collection can receive a browser data item that Puppeteer does not know how to represent. Reading POST data exercises that conversion.

The failing snippet uses a WebDriver BiDi page named page that is about to send a POST request with an unsupported collected body item.

const request = await page.waitForRequest(
    (request) => request.method() === "POST"
);

const body = await request.fetchPostData();

console.log(body);

A normal string POST body does not reproduce this error. The example shows the body-reading operation; the browser must supply the unsupported item type.

How to fix

For requests you own, use an explicit supported payload representation such as a JSON string. That avoids depending on an unsupported request-body item type.

const payload = {
    name: "Ada",
};

await page.evaluate(
    async (data) => {
        await fetch("/api/profile", {
            method: "POST",
            headers: {
                "content-type": "application/json",
            },
            body: JSON.stringify(data),
        });
    },
    payload
);

Things to keep in mind

The page must have a working same-origin /api/profile endpoint. This changes the outgoing payload and is only appropriate when you own that request. A third-party unsupported body type may require a browser/Puppeteer fix rather than an application snippet.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →