MuleSoft: Payload not Displaying as Expected in Response

188 Views Asked by At

I'm currently working with an IT company, and MuleSoft is relatively new to me. While I've learned quite a few things, I'm encountering an issue.

My problem is that whenever I attempt to set a payload to display a specific value, it doesn't appear as expected in the response body, even when I hard code it in the transform message at the end of the flow.

What could possibly be causing this issue? Am I missing something in my configuration?

1

There are 1 best solutions below

0
On

In the absence of your specific code, I'll provide an example based on my understanding of your use case. To proceed, please follow these steps:

  1. Create a new project named 'mule-test'.

  2. Replace the entire 'mule-test.xml' mule configuration file with the provided code below.

  3. After deploying the application, you can access it using the following URL: http://localhost:8081/test.

    <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
     xmlns="http://www.mulesoft.org/schema/mule/core"
     xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
     http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
     <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="4e5f4a85-7fbf-4574-adfa-6bf29817a9d1" >
         <http:listener-connection host="0.0.0.0" port="8081" />
     </http:listener-config>
     <flow name="mule-testFlow" doc:id="e09a142b-8597-4f90-a4f7-e4df8cb158a9" >
         <http:listener doc:name="Listener" doc:id="b219dc15-d4ec-4334-80f3-c8f48bfb9c67" config-ref="HTTP_Listener_config" path="/test"/>
         <ee:transform doc:name="Transform Message" doc:id="de99c1be-5fbc-43bd-9b94-7660dfef8210" >
             <ee:message >
                 <ee:set-payload ><![CDATA[%dw 2.0 output application/json --- {
     "Key1": "Value1",
     "Key2": "Value2" }]]></ee:set-payload>
             </ee:message>
         </ee:transform>
     </flow> 
    

Providing a screenshot while testing the application using Postman: enter image description here