0
votes

I have an api developed and want to consume this api in a mule flow.
But when I test from chrome:postman I am getting the below error.

Message payload is of type: BufferInputStream

So I tried to log the message and below I got

org.glassfish.grizzly.utils.BufferInputStream@e2ed077

So basically my requirement is how can I pass json payload to my api. Below is my code snippet.

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8083" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="localhost" port="8082" doc:name="HTTP Request Configuration">
    <http:basic-authentication username="sa" password="sa"/>
</http:request-config>
<flow name="get-response-container-storeFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/testapi" doc:name="HTTP"/>
    <logger message="******************Executed Test_Container_Store_API*******************#[payload]" level="INFO" doc:name="Logger"/>
    <logger message="#[payload]" level="INFO" doc:name="Logger"/>
    <http:request config-ref="HTTP_Request_Configuration" path="/apie" method="POST" sendBodyMode="NEVER" doc:name="HTTP">
    </http:request>
1

1 Answers

0
votes

You can resolve the first "error" with the logger by addding a <object-to-string-transformer/> as the first message processor after your http:inbound (or more importantly, before your logger).

If you want to include the body in the request you should remove the sendBodyMode="NEVER" attribute from your request.

From the MuleSoft docs:

By default, the methods GET, HEAD and OPTIONS sends HTTP requests with an empty body, and the payload of the Mule message won’t be used at all. The rest of the methods sends the message payload as the body of the request. If you need to change this default behavior, you can specify the sendBodyMode attribute in the request, with one of the following possible values:

AUTO (default): The behavior depends on the method. Body is not sent for GET, OPTIONS and HEAD, and it is sent otherwise.

ALWAYS: The body is always sent.

NEVER: The body is never sent.

This means since you have this attribute set to never your payload will never be included as the request-body.