Contact Us 1-800-596-4880

Set Payload Transformer

Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule reached its End of Life on November 2, 2022, when Extended Support ended.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

The Set Payload (set-payload) component lets you update the payload of the message. The payload can be a literal string or a DataWeave expression. The set-payload component, however, is not recommended for complex expressions or transformations but rather, simple ones, such as selections. You should use Transform Message Component for complex scenarios.

Field Usage Description

Value (value)

Required

Accepts a literal string or DataWeave expression that defines how to set the payload, for example, "some string" or #[now()].

Mime Type (mimeType)

Optional

The mime type of the value assigned to the payload, for example, text/plain or application/json.

Encoding (encoding)

Optional

The encoding of the value assigned to the payload, for example, UTF-8.

The mimeType and encoding attributes will not affect a DataWeave expression used as value. They only affect the output Mule Message. If a transformation is required, the DataWeave expression must contain an explicit output directive.

This XML example sets a payload with static values:

Static Content Example:
<set-payload value="{ 'name' : 'Ana', 'office' : 'BA' }" mimeType="application/json" encoding="UTF-8"/>

The next example sets the message payload to "Hello, World" appending today’s date using a DataWeave expression: #['Hello World!' ++ ' Today is ' ++ now()]

Expression Content Example:
<set-payload value="#['Hello World!' ++ ' Today is ' ++ now()]"/>