Skip to content

Form-data body sent as JSON instead of multipart/form-data #70

@danydossantos63

Description

@danydossantos63

🐛 Bug: Form-data body sent as JSON instead of multipart/form-data

Description

When using the "Form-data" body format, the request body seems sent as JSON instead of proper multipart/form-data, causing APIs that strictly validate the format to reject the request.

Steps to reproduce

  • Set method to POST
  • Select Body format: Form-data
  • Add key-value body:
    • image_token: 32ea5e95-8025-459d-94b6-sd4rg411rtgv1s8f
  • Set header:
    • Content-Type: multipart/form-data
  • Send request

Actual behavior

The API returns:

400: {"detail":"There was an error parsing the body"}

The plugin sends the payload using json= (in rest_api_client.py):

elif body_format in [DKUConstants.FORM_DATA_BODY_FORMAT]:
    key_value_body = endpoint.get("key_value_body", {})
    self.requests_kwargs.update({"json": get_dku_key_values(key_value_body)})

This results in a JSON body instead of multipart/form-data, even if the header is manually overridden.

Expected behavior

The Form-data format should use files= to properly encode the request:

self.requests_kwargs.update({
    "files": {k: (None, v) for k, v in body_dict.items()}
})

This would generate a valid multipart/form-data request with correct boundaries.

Additional context

Using the Raw body format with manually crafted multipart content also fails due to incorrect line endings (\n instead of \r\n).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions