From c6bebc815732d9de0c6ac7ea426469131c72e558 Mon Sep 17 00:00:00 2001 From: JimHeo Date: Wed, 19 Feb 2025 15:41:27 +0900 Subject: [PATCH] fix: missing boundary in multipart/form-data error --- api/core/tools/custom_tool/tool.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/core/tools/custom_tool/tool.py b/api/core/tools/custom_tool/tool.py index f8467c54c5..8a0163760e 100644 --- a/api/core/tools/custom_tool/tool.py +++ b/api/core/tools/custom_tool/tool.py @@ -211,6 +211,12 @@ class ApiTool(Tool): body = urlencode(body) else: body = body + + # if there is a file upload, remove the Content-Type header so that httpx can automatically generate the boundary header required for multipart/form-data. + # issue: https://github.com/langgenius/dify/issues/13684 + # reference: https://stackoverflow.com/questions/39280438/fetch-missing-boundary-in-multipart-form-data-post + if files: + headers.pop("Content-Type", None) if method in { "get",