danw
danw

Reputation: 1648

Mule HTTPS POST request not working when deployed to Cloudhub

I have a Mule application that is calling an external API over HTTPS using the <http:request connector. When I build and deploy my application locally, the call works fine. When I make a Postman call to the same external API using the exact same payload my Mule app sends, the call works fine. However, when I deploy the Mule app to Cloudhub and make the request - I get a 400 response from the external API.

Here's my flow:

<http:request-config name="mambuRequestConfiguration" protocol="HTTPS" doc:name="HTTP Request Configuration">
    <http:basic-authentication username="${mambu.username}" password="${mambu.password}" preemptive="true" />
    <tls:context>
        <tls:key-store type="jks" path="keystore.jks" alias="${keystore.alias}" keyPassword="${keystore.keypassword}" password="${keystore.password}" />
    </tls:context>
</http:request-config>

<flow name="createClientDepositAccount">
    <dw:transform-message metadata:id="412fd434-12bb-47a3-9605-9bfc1d9fec46" doc:name="Transform Message">
        <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
savingsAccount: {
    accountHolderKey: payload.clientKey,
    accountHolderType: "CLIENT",
    productTypeKey: payload.productKey,
    name: payload.clientProductName,
    accountType: payload.accountType,
    accountState: payload.accountState,
    interestRate: payload.interestRate
}
}]]></dw:set-payload>
    </dw:transform-message>
    <http:request config-ref="mambuRequestConfiguration" path="${mambu.deposit.path}" method="POST" host="${mambu.host}" port="${mambu.port}" doc:name="Mambu: Create Client Deposit Account">
        <http:success-status-code-validator values="0..599"/>
    </http:request>
    <dw:transform-message metadata:id="49f1231f-485f-433c-82c4-3d83856ac442" doc:name="Transform Message">
        <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
message: "Account created successfully",
key: payload.savingsAccount.encodedKey
}]]></dw:set-payload>
    </dw:transform-message>
</flow>

The external service I'm calling is Mambu, a cloud banking platform. I have a number of other flows in my application all making GET requests to various other Mambu APIs - all work fine (all GET requests are also over HTTPS). The response I'm getting from Mambu is a 400 with the payload:

{"returnCode":3,"returnStatus":"INVALID_API_OPERATION"}

Relevant links to the Mambu documentation are here and here.

I'm unable to replicate the behaviour I'm seeing in Cloudhub on my local instance. The only thing that differs about this call to the others I'm making is that it's a POST request.

Upvotes: 1

Views: 2886

Answers (3)

HotBloodAunt
HotBloodAunt

Reputation: 1

Make sure to use https:// instead of http:// for the post address in Postman when making calls to the Mulesoft cloudapp.

Upvotes: 0

granthbr
granthbr

Reputation: 311

In most cases this error is related to the API auto-discovery being improperly configured or corrupt. If API auto-discovery is configured on the Mule application, the best solution is to remove the setting from the Mule application, check if the error is resolved by starting the process again, then reconfigure the auto-discovery.

Upvotes: 1

danw
danw

Reputation: 1648

Bizarrely, the resolution to this was "turn it off and on again" as suggested on a question I posted on the Mulesoft forum. I simply deleted the app from Cloudhub and redeployed it and everything worked as expected. Very strange issue within Cloudhub by the looks of things. Hopefully Mulesoft will resolve...

Upvotes: 0

Related Questions