Skip to content

[Question]: How to retrieve form data from Playwright Request object? #1064

@yannsartori

Description

@yannsartori

Your question

I am adding a custom route handler to a Playwright page and I am trying to inspect the request passed into the handler. For context here is a following code snippet:

def handler(route: Route, request: Request):
    # Do things with `request`
    ...

await page.route('**/*', handler=handler)

For POST/PUT requests with a Content-Type of application/json, I have been able to successfully inspect the payload by using request.post_data_buffer. However, when the Content-Type is multipart/form-data, I have not been able locate where I can get the form data. All of the post_data, post_data_buffer, and post_data_json properties have a value of None, and I couldn't see anything else in the documentation which could contain the form_data.

I added a similar question to the generic playwright GitHub here

Could this also be a bug? I was not sure which is why I hesitated to open this as a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions