Search code examples
mulemime-typesmule-studiopayloaddataweave

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.


Solution

  • 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.