0
votes

I am trying to send a simple POST request to some end point where I know it is possible and working as I am able to send it through SoapUI and Chrome Rest console. A successfull request looks like this one on the picture:

enter image description here

I have been trying to send it through Mule with no success. I am setting the payload to be a java.util.Map that will contain all parameters I want to be sent as content but I am continuously getting response 400 Wrong request. This is how it looks right now:

enter image description here

And this is how our request looks like:

<http:request config-ref="HTTP_Request_Configuration1" path="api/token/" method="POST" doc:name="GetToken" parseResponse="false">
        <http:request-builder>
        </http:request-builder>
    </http:request>

I would guess that I am missing something very little as setting. Can someone help?

Or if someone knows what is easiest way to see the exact request that is being sent through Mule? Or some other way to see the request that is being sent?

Thanks!

2
Could you please share the entire flow (including the HTTP Request config)? Also, keep in mind that you'll have to set up all headers in the request-builder section the same as you are doing with the REST console. - afelisatti
@afelisatti Here is the config: <http:request-config name="HTTP_Request_Configuration1" protocol="HTTPS" host="correctsitehere.net" port="443" doc:name="HTTP Request Configuration"> Isn't it by default that when sending POST, a Content-type and legth are also included? - Stanislav Ivanov
Yes, but if there's anything extra you are sending you need to specify it. I'd try setting the payload to a plain HashMap instead of a LinkedHashMap, which is what I guess you are setting in the JSON to object transformer from the debug capture. - afelisatti
I changed the load from HashMap to plain old String, because the load was supposed to look like this: username=uuuu&password=ppppp&grant_type=password. After that I set Content-Length and type and it worked. How about adding this to the original documentation about the HTTP component? - Stanislav Ivanov

2 Answers

0
votes

I saw that the information that is send looks like this: username=uuuu&password=ppppp&grant_type=password. That's why I changed the type of the payload from HashMap to String, set it with the parameters I wanted, added Content-Type and Content-Legth as headers in the http request and it worked fine.

0
votes

You are using Json to Object Transformer you doesn't need it since you are using form parameters you need to add the parameters required for the service you are invoking.