HTTP POST API returns HTML --> How to handle this?

Hi there, I have to consume an API (Adyen HPP) that returns HTML because the request will redirect me to a website. To call the API, I have to do a POST with Content-Type: application/x-www-form-urlencoded The call redirects me to a hosted payment page on the website. This all works fine when trying it with Postman Does anyone know how to achieve this in Mendix? When calling the rest service, it returns HTML. Instead of this, I want to be redirected to the website. I would like to the POST request on the client-side. Any ideas?  Thanks! EDIT: here is how we solved it: We first built a custom request handler so we could go 'outside' of the hybrid app and into the browser. The custom request handler triggers logic that POSTs the following form to the browser: <html> <body> <form method="post" action="'+@AdyenIntegration.ADYEN_PAYMENT_URL+'" name="adyenForm" target="_self" enctype="application/x-www-form-urlencoded"> <input hidden name="merchantSig" value="'+$MerchantSig+'"/> <input hidden name="merchantReference" value="'+$NewPaymentRequest/merchantReference+'"/> <input hidden name="paymentAmount" value="'+$NewPaymentRequest/paymentAmount+'"/> <input hidden name="currencyCode" value="'+$NewPaymentRequest/currencyCode+'"/> <input hidden name="shipBeforeDate" value="'+$NewPaymentRequest/shipBeforeDate+'"/> <input hidden name="skinCode" value="'+$NewPaymentRequest/skinCode+'"/> <input hidden name="merchantAccount" value="'+$NewPaymentRequest/merchantAccount+'"/> <input hidden name="sessionValidity" value="'+$NewPaymentRequest/sessionValidity+'"/> <input hidden name="merchantReturnData" value="'+$NewPaymentRequest/merchantReturnData+'"/> <input hidden name="shopperEmail" value="'+$NewPaymentRequest/shopperEmail+'"/> <input hidden name="resURL" value="'+$NewPaymentRequest/resURL+'"/> </form> <script type="text/javascript"> window.onload = function(){ document.forms["adyenForm"].submit(); } </script> </body> </html>          
2 answers

If you call needs to be done client-side have you tried making the request in js or jQuery?

You can create the button and attach an event that does the API call with some js/jQuery using the HTML Snippet widget.

Here’s a stack overflow topic on js/jquery api calls using JSON in case you need a reference to build the call – 

Hope this helps 


Does the html response that you see now have a Location header? You could add another REST call to that location.