<set-payload
value=""
doc:name="Set payload"
doc:id="vnjpqo" />
xml
Set Payload (<set-payload/>)
Sets or updates the payload of the message.
The payload can be a literal string or a DataWeave expression. Use the set-payload
component only for simple expressions or transformations.
For complex scenarios, use the Transform Message Component.
Component XML
This component supports the following XML structure:
Set Payload (<set-payload/>
) attributes are configurable through the UI and XML.
Attribute Name | Attribute XML | Description |
---|---|---|
Set payload (default) |
|
Editable name for the component to display in the canvas. |
N/A |
|
Automatically generated identifier for the component. |
Value |
|
A literal string or DataWeave expression that defines how to set the payload, for example, |
N/A |
|
A |
Encoding |
|
Encoding of the payload that this component outputs. |
Mime type |
|
MIME type of the payload that this component outputs. For more information, see Using Reader and Writer Properties. |
Parameters |
N/A |
Appends a key-value pair for a reader property to the value of the |
The |
Examples
The following examples show how to set the payload using a static value or a DataWeave expression.
Example: Set the Payload with a Static Value
The following example sets a payload with static values:
<set-payload value="{ 'name' : 'Ana', 'office' : 'BA' }" mimeType="application/json" encoding="UTF-8"/>
xml
Example: Set the Payload Using a DataWeave Expression
The following example sets the message payload to "Hello, World"
appending today’s date using a DataWeave expression:
#['Hello World!' ++ ' Today is ' ++ now()]
<set-payload value="#['Hello World!' ++ ' Today is ' ++ now()]"/>
xml