🐛 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).
🐛 Bug: Form-data body sent as JSON instead of
multipart/form-dataDescription
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
POSTimage_token:32ea5e95-8025-459d-94b6-sd4rg411rtgv1s8fContent-Type: multipart/form-dataActual behavior
The API returns:
The plugin sends the payload using
json=(inrest_api_client.py):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:This would generate a valid
multipart/form-datarequest with correct boundaries.Additional context
Using the Raw body format with manually crafted multipart content also fails due to incorrect line endings (
\ninstead of\r\n).