
Hi,
I'm new on mule and I try to replace a curl expression with the Mule HTPP connector :
curl 'https://my-test-dns/api/login' -X POST -H 'Accept: application/json' -H 'Content-Type: application/json; charset=UTF-8' -d '{ "username" : "myuser", "password" : "mypassword"}'
in Mule I've currently configure this the connection seems ok because I receive an HTTP 400 but I expect that the Body of the http post is not correctly formated
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:tls="http://www.mulesoft.org/schema/mule/tls" xmlns:batch="http://www.mulesoft.org/schema/mule/batch"
xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:request-config name="HTTPSGetUnboxToken" protocol="HTTPS" host="my-test-dns" port="443" basePath="/" doc:name="HTTP Request Configuration">
<tls:context>
<tls:trust-store insecure="true"/>
</tls:context>
</http:request-config>
<flow name="cafetariaplanFlow">
<file:inbound-endpoint path="C:\AnypointStudio\TestCases\PlanCafetaria\Input" moveToDirectory="C:\AnypointStudio\TestCases\PlanCafetaria\Work" responseTimeout="10000" doc:name="File"/>
<file:file-to-string-transformer doc:name="File to String"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<http:request config-ref="HTTPSGetUnboxToken" path="api/login" method="POST" source="# [message.payload]" requestStreamingMode="NEVER" sendBodyMode="ALWAYS" doc:name="HTTPS">
<http:request-builder>
<http:header headerName="Content-Type" value="application/json; charset=UTF-8"/>
</http:request-builder>
</http:request>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
input file contain :
{
"username" : "myuser",
"password" : "mypassword"
}
any help will be appreciate,
Thanks in advance
Pascal.
Path looks ok but you have not shown return output in issue. You can use another transformer like Object to JSON after HTTPS component to produce formatted JSON.