I have a scenario where I need to call a POST API that returns an HTML response. I want to display this HTML content inside an IFrame on a Freedom UI page.
Since the standard IFrame component accepts a URL
(which works with GET
), I’m not sure about the best approach to:
- Make a
POST
request, - Get the HTML, and
- Load it into the IFrame component.
Is there a recommended way to do this in Creatio?
Has anyone implemented this similar solution using a client module or custom JS?
Any examples or best practices would be greatly appreciated!
Thank you in advance for your help.
Like
Hi Ajay,
While the standard IFrame functionality in Freedom UI is designed for displaying external content via a static URL (typically supporting GET requests), rendering the result of a POST request requires a different approach.
The recommended solution is to implement a custom Freedom UI component using a remote module. This allows you to perform the POST request, handle the HTML response, and display the result directly within the page.
Within this custom component, the implementation typically involves the following steps:
1. Perform the POST request using Angular to retrieve the HTML content from the API.
2. Render the result by either inserting the HTML into the page using innerHTML, or by converting it into a Blob or data URI and setting it as the src of an iframe.
You can refer to the official documentation for implementing remote modules here:
https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/front-end-development/freedom-ui/remote-module/implement-a-remote-module/overview
https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/front-end-development/freedom-ui/remote-module/implement-a-remote-module/examples/implement-a-remote-module
Additionally, the following article demonstrates how to embed an iframe within a Freedom UI component:
https://customerfx.com/article/embedding-an-iframe-on-a-creatio-freedom-ui-page/