How to show REST HTML results

0
 hi,    I have an api, calling the API via browser results in the following:   I am using a Microflow with a Call REST (GET) activity to call the API but am not sure how to get the same results to display via Mendix. I have tried to use options via the Response Handling dropdown in the Response tab from the Call Rest Service activity in the Microflow but to no avail.    I have also searched for similar needs but have not chanced upon anything similar - apart from HTML Element widget which I'm not sure can assist.   I would be grateful for any assistance in displaying the results either from a Mendix page or in an external browser.    I'm a bit lost here if I'm honest - sorry about that but any help would be brill.   PS: I  can also return results as pdf if that is easier to handle in Mendix?   thank you in advance,   Regards,   Michael      
asked
4 answers
1

Hi Michael,

The API returns an HTML page

1) Is your response like text/HTML format, like below as a string
 

<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
  <tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
  </tr>
  <tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
  </tr>
  <tr>
    <td>Laughing Bacchus Winecellars</td>
    <td>Yoshi Tannamuri</td>
    <td>Canada</td>
  </tr>
  <tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
  </tr>
</table>

For this, you can set the response variable in 

If so, you can store it in a string attribute and use an HTML Element to show the HTML in UI. 

Screenshot 2025-09-02 152006.png

** Note: if you have a full HTML code, the styles element in the header might not apply; prefer inline-styled HTML if possible.

Or if you have the same format(fixed) for all API's then you can add the styles in Mendix when developing and let them get applied/ you can also style them from your app once on how a table should look. and add the parent class to activate styles specific to api resulted ones.

 

2) Or a URL/ link as a string like 'https://exampl.com', then follow below, you can set styles and other attributes in the HTML Attributes section

image.png

 

 

answered
0

If the API returns an image (e.g., image/jpeg)

  1. Create an entity ApiImage that generalizes System.Image (no extra attributes needed).

  2. Microflow (on a button):

    • Create object ApiImage (set Name = “m11.jpg” optional).

    • Call REST (GET)Response handling = “Store in a file document” → target $ApiImage.

      • Add header Accept: image/jpeg (if needed).

      • Add Authorization header if the API needs it.

    • Commit $ApiImage (optional).

    • Show page with a Data view of ApiImage and an Image widget inside.(Alternative: use Download file on $ApiImage to open it in a new browser tab.)

If the API returns a PDF (application/pdf)

  1. Create an entity ApiFile that generalizes System.FileDocument.

  2. Same microflow pattern as above, but:

    • Response handling → Store in a file document$ApiFile.

    • Header Accept: application/pdf (if needed).

    • After the call, use Download file ($ApiFile) to open in a new tab, or place a PDF/File viewer widget on a page bound to $ApiFile.

If the API returns an HTML page

  • Easiest: use a Link button or Open URL microflow action to open the API URL in a new tab.

  • Embedding via iframe works only if the server allows it (no X-Frame-Options: DENY).

Common gotchas

  • Don’t use “Apply mapping/Convert to string” for images/PDFs—use “Store in a file document.”

  • Make sure required headers (Authorization, Accept) are set.

  • If you get an empty file, the call likely failed auth; check the HTTP Response (status/body) in the Call REST activity.

answered
0

Hi,

 

Thank you for your response. I am focusing on HTML:

If the API returns an HTML page

  • Easiest: use a Link button or Open URL microflow action to open the API URL in a new tab.

In relation to the Open URL microflow action you mention - I am unable to locate this feature from either a microflow activity or functionality. I would be grateful if you could elaborate, my apologies. 

 

My Microflow currently look like this:

 

m12.jpg

 

In relation to using a Link button, again I am a bit confused as to how to achieve this - In terms of the response handling, I tried to store this in a string (and other options) but do not see how I can include this on a page outside of the microflow - I tried the link button but was not able to use this to include the variable created via the Call REST Response tab.

 

Any further assistance is greatly appreciated,

 

Regards,

 

Michael 

 

 

answered
0

Thanks Mohana Vyshnavi,

I was able to solve the problem by constructing a string of the api + parameters and then passing that string to a link button - this opens a new browser window with the results. 

 

I would prefer to have the results displayed in Mendix so attempted your method. The steps I took:

 

Created a microflow and used the string of the api + parameters as the Location 

 

m14.jpg

 

I then selected Store in a string as Response Handling from the Response tab

 

m15.jpg

 

I then create a blank page to use the variable Analysis_results via HTML ELement

m16.jpgHowever, the variable does not appear - can you tell me what I am doing wrong from the screenshots?

 

NOTE: I also tried to store the string containing the response to a string attribute in an entity and then calling that from HTML Element but as this is an object it cannot be used.

 

Thanks for any help with this

 

Regards,

Michael

 

 

 

 

answered