Retrieving the content of a message

During the API transactions, you can retrieve the content of specific properties of a message, for example, the payload or headers of the message.

For assembly actions where you must specify an input or output message, the message is stored in a specified variable in the API context. Then, you can use these variables to retrieve the content of specific properties of the message. For example, the payload or headers of the message. The message can be created by one of the following ways.
  • The request or message message is automatically created at the beginning of each API transaction.
  • A message can be created for storing the output of an assembly action. For example, an output message is created by the invoke action. In assembly actions that generate the output message, you need to specify the name of a variable for the output message to be created. The default variable name is message that represents the current message during API processing.

    The variable cannot be any read-only variables in the API context.

    Assembly actions that generate the output message.
    • Invoke
    • JSON to XML
    • Parse
    • XML to JSON
To retrieve the content of specific property of a message, follow these formats, where the messageName variable represents the message name.
messageName.body
Represents the payload of the message.
messageName.headers
Represents all headers of the message.
messageName.status.code
Represents the status code of the message.
messageName.status.reason
Represents the status reason of the message.
messageName.variables.propName
Represents the propName property that is associated with the message. The property can be created with the apigw:set-variable extension element. For example, when foo is the property of the msg message object, you can retrieve the value of the foo property by reading msg.variables.foo.