diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index 4db1c3546..d9645ce3d 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -51,13 +51,20 @@ def _get_kwargs( {% set destination = "_" + body.body_type + "_body" %} {{ body_to_kwarg(body, destination) | indent(8) }} _kwargs["{{ body.body_type.value }}"] = {{ destination }} + {% if body.content_type == "multipart/form-data" %} + headers["Content-Type"] = "multipart/form-data; boundary=+++" + {% else %} headers["Content-Type"] = "{{ body.content_type }}" + {% endif %} + {% endfor %} {% elif endpoint.bodies | length == 1 %} {% set body = endpoint.bodies[0] %} {{ body_to_kwarg(body, "_body") | indent(4) }} _kwargs["{{ body.body_type.value }}"] = _body - {% if body.content_type != "multipart/form-data" %}{# Need httpx to set the boundary automatically #} + {% if body.content_type == "multipart/form-data" %} + headers["Content-Type"] = "multipart/form-data; boundary=+++" + {% else %} headers["Content-Type"] = "{{ body.content_type }}" {% endif %} {% endif %}