Mule 4:HTTP 请求者:如何将 multipart/form-data 作为 POST 主体发送给 Mule REST 服务调用?

Mule 4 : HTTP Requester : How to send multipart/form-data as POST Body for Mule REST Service Call?

场景:

我必须从 Mule 4 内部进行 REST 服务调用并将 multipart/form-data 作为 POST 正文发送。

为了在 Dataweave 中形成 multipart/form 数据,我执行了以下操作:

%dw 2.0
output multipart/form-data 
---
{
    parts: {
        Field1: {
            headers : {
                "Content-Type": "text/plain"
            },
            content: "Value1"
        },
        Field2: {
            headers : {
                "Content-Type": "text/plain"
            },
            content: "Value2"
        },
        Field3: {
            headers : {
                "Content-Type": "text/plain"
            },
            content: "Value3"
        }
    }
}

然后在 HTTP Request 中,我在 HTTP Requester Body 中设置了负载。

但是当我进行 REST API 调用时,出现错误 Missing Field1

有什么解决办法?

这对我来说效果很好:

        <ee:transform doc:name="Transform Message">
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output multipart/form-data 
---
{
    parts: {
        Field1: {
            headers : {
                "Content-Type": "text/plain"
            },
            content: "Value1"
        },
        Field2: {
            headers : {
                "Content-Type": "text/plain"
            },
            content: "Value2"
        },
        Field3: {
            headers : {
                "Content-Type": "text/plain"
            },
            content: "Value3"
        }
    }
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <http:request method="POST" doc:name="Request" config-ref="HTTP_Request_configuration" path="/backend" >
        </http:request>