Tomeister
Tomeister

Reputation: 716

How to get payload mime type in Mule 4

I am trying to find out what is the payload type by printing it out using logger. I am aware that in Mule 3 you could use this #[payload.getClass().getSimpleName()] or #[message.dataType.type].

How to achieve this in Mule 4? I did my google search but could not find any solution.

Upvotes: 2

Views: 10518

Answers (2)

zdenekca
zdenekca

Reputation: 1172

Get payload media type: #[payload.^mediaType]

Reference: https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook-extract-data

Upvotes: 2

Ryan Carter
Ryan Carter

Reputation: 11606

You can use:

#[payload.^class]

Try logging:

#[payload.^]

Should print:

{class=java.util.ArrayList, encoding=UTF-8, mimeType=application/java, raw=[{}]}

But if your payload is not application/java mime/type but json or something instead it won't have class attribute.

Upvotes: 4

Related Questions