Skip to content

[Bug]: APIRequestContext multipart parameter does not allow user to send multiple files in a single field #2784

Open
@adriangardiner-taina

Description

@adriangardiner-taina

Version

1.50.0

Steps to reproduce

Setup a multipart data object with an array of files being sent in a single field using the ApiRequestContext object

multipart_data = {
    files= [ 
        { "name"="Document1.txt", "mimeType":"text/plain", buffer: b"Text file 1 content" },
        { "name"="Document2.txt", "mimeType":"text/plain", buffer: b"Text file 2 content" }
    ]
}

Attempt to send this to an API endpoint that expects to find a list of files against the field named "files".

Example steps : TBC

Expected behavior

I expect to receive a list of files in my API endpoint in a single form field.

Actual behavior

0 files are sent to the API Endpoint.

Additional context

Issue has been identified in playwright/_impl/_fetch.py#L382

Suggest an extra helper method and foreach loop added to identify and attach arrays of file payloads

Environment

- Operating System: [Windows 10]
- CPU: [Intel i7]
- Browser: [All]
- Python Version: [3.11.6]
- Other info:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions