# Visualize Html Not Working

**URL:** <https://community.postman.com/t/visualize-html-not-working/53257>\
**Category:** Help Hub\
**Tags:** tests, response, visualizer\
**Created:** [October 13, 2023, 4:40pm UTC](https://community.postman.com/t/visualize-html-not-working/53257 "2023-10-13T16:40:16Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![baha-bayar](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@baha-bayar](https://community.postman.com/u/baha-bayar)\
**Post date:** [October 13, 2023, 4:40pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/1 "2023-10-13T16:40:16Z")

</div>

My response html like this

```auto
<!doctype html>
<html lang="en">
<head>
    <title>test Mock 3D-Secure Processing Page</title>
</head>
<body>
<form id="test-3ds-form" action=" *******************************************************" method="post">
    <input type="hidden" name="orderId" value=" *******************************************************" />
    <input type="hidden" name="bin" value="123123123" />
    <input type="hidden" name="successUrl" value=" *******************************************************" />
    <input type="hidden" name="failureUrl" value=" *******************************************************" />
    <input type="hidden" name="confirmationUrl" value=" *******************************************************" />
    <input type="hidden" name="PaReq" value=" *******************************************************" />
</form>
<script type="text/javascript">
    document.getElementById("test-3ds-form").submit();
</script>
</body>
</html>

```

and my tests script like this

```auto

const htmlContent = pm.response.json().htmlContent;

function fixHTML(html) {

const fixedHTML = html.replace(/<input(.*?)>/g, '<input$1 />');

const cleanedHTML = fixedHTML.replace(/onclick=".*?"/g, '');

return cleanedHTML;

}

const fixedHTMLContent = fixHTML(htmlContent);

// Set the visualizer template and payload

pm.visualizer.set(fixedHTMLContent);

```

Tests script working but not visualizing anything. How can i fix it ?

 ![resim](https://us1.discourse-cdn.com/getpostman/original/3X/d/b/dbcbc42dec1e5e97613e49da14eb0b6d58e2347b.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 13, 2023, 5:08pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/2 "2023-10-13T17:08:31Z")

</div>

Hey @baha-bayar

Welcome to the Postman Community! :postman:

I’m not sure I follow what you have in place here, is the response from your API HTML or JSON?

I’m confused by this line:

```auto
const htmlContent = pm.response.json().htmlContent;

```

I’d recommend taking a look through the learning center, to get more of an idea about how you can visualize your responses:

> **[Visualize request responses using Postman Visualizer | Postman Learning Center](https://learning.postman.com/docs/sending-requests/visualizer/)**
>
> Visualize request responses using Postman Visualizer: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

This link also contains example references that you can take a look through.

---

<div class="post-metadata">

**Author:** ![baha-bayar](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@baha-bayar](https://community.postman.com/u/baha-bayar)\
**Post date:** [October 13, 2023, 5:38pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/3 "2023-10-13T17:38:01Z")

</div>

It’s my api response and my body like this  
{  
“htmlContent”: “My Html Content Is Here”  
“status”: “success”,  
“errorCode”: null,  
“errorMessage”: null,  
“errorGroup”: null,  
“locale”: “tr”,  
“systemTime”: 1697216390962,  
“conversationId”: “123456789”  
}

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 16, 2023, 12:16pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/4 "2023-10-16T12:16:33Z")

</div>

What are you trying to do with that HTML?

It looks like a form.

You won’t be able to interact with it, as JavaScript is disabled in the visualize tab.

Therefore I suspect that the form and script block will just be ignored and produce a blank page.

---

<div class="post-metadata">

**Author:** ![xk0der](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/xk0der/32/2056_2.png) [@xk0der](https://community.postman.com/u/xk0der)\
**Post date:** [October 16, 2023, 9:10pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/5 "2023-10-16T21:10:19Z")

</div>

visualizer[can display form elements and run scripts.](https://learning.postman.com/docs/sending-requests/visualizer/)

**Looking at the visualizer code in the question, it’s trying to submit the form. I do not think that is supported!**  
_Possibly because there would be security implications 🤷 . Someone from Postman can provide an official reasoning._

After removing `type="hidden"` and the JavaScript code to submit the form, I’m able to view it in the visualizer.

 ![Screenshot 2023-10-17 at 09.55.28](https://us1.discourse-cdn.com/getpostman/original/3X/4/9/49bea9b8185dcb37f972a85f767f8386cbb9b411.png)

With the submit code, I can see it’s being cancelled. I tested using both localhost and an external domain.

 ![Screenshot 2023-10-17 at 09.57.23](https://us1.discourse-cdn.com/getpostman/original/3X/a/3/a32ad8c37e1f53213f3d77b98778269ffa0d50b3.png)

Visualizations can be [debugged by right clicking on the visualization pane](https://learning.postman.com/docs/sending-requests/visualizer/#debugging-the-visualizer) and selecting `Inspect visualization`  
 ![Screenshot 2023-10-17 at 10.02.56](https://us1.discourse-cdn.com/getpostman/original/3X/e/1/e1656b371277a7419bce9945ceb0a3032db57391.png)

* * *

**I tested using similar code as @baha-bayar**

```auto
// Not sure why we need this?
function fixHTML(html) {
    const fixedHTML = html.replace(/<input(.*?)>/g, '<input$1 />'); 
    const cleanedHTML = fixedHTML.replace(/onclick=".*?"/g, ''); 

    return cleanedHTML;
}

const htmlContent = pm.response.json().data; // HTML will be inside this field when using postman-echo.com
const fixedHTMLContent = fixHTML(htmlContent);

pm.visualizer.set(fixedHTMLContent);

```

And using `postman-echo.com` as follows

 ![Screenshot 2023-10-17 at 10.05.11](https://us1.discourse-cdn.com/getpostman/original/3X/b/e/bee88660001d93ec415e2b38c7f5553aae5e260a.png)

---

<div class="post-metadata">

**Author:** ![xk0der](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/xk0der/32/2056_2.png) [@xk0der](https://community.postman.com/u/xk0der)\
**Post date:** [October 17, 2023, 12:12am UTC](https://community.postman.com/t/visualize-html-not-working/53257/6 "2023-10-17T00:12:03Z")

</div>

@baha-bayar thinking more about your use-case. Doesn’t look like you are after visualizing the response, instead you want to submit the data in the form. Do clarify, if that’s not the case. 🙂

Based on my assumption about your use-case, I suggest you [parse the HTML](https://cheerio.js.org/) response using [cheerio](https://cheerio.js.org/) library available within Postman’s sandbox, to setup a request directly in postman and execute that.

To get you started, the following code will return all the input elements inside the form:

```auto
const htmlContent = pm.response.json().htmlContent
const $ = cheerio.load(htmlContent);

let inputElements = $("form[id='test-3ds-form'] input");
let actionURL = $("form[id='test-3ds-form']")[0].attribs.action;

console.log(inputElements); // Check Postman's console to view the elements data
console.log(actionURL);

```

Next you can read the `attribs` field and extract the field `name` and `value`, store them in Environment (or Collection) variables. That can be used in the next Postman request. I leave this as an exercise for you.

You should then be able to view the response of the request directly within Postman, under the `Preview` tab.

---

<div class="post-metadata">

**Author:** ![baha-bayar](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@baha-bayar](https://community.postman.com/u/baha-bayar)\
**Post date:** [October 17, 2023, 3:58pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/7 "2023-10-17T15:58:14Z")

</div>

I think thats the reason , 2 years ago i try the same think but it works may be they blocked for some reason.

---

<div class="post-metadata">

**Author:** ![baha-bayar](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@baha-bayar](https://community.postman.com/u/baha-bayar)\
**Post date:** [October 17, 2023, 4:13pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/8 "2023-10-17T16:13:54Z")

</div>

Thank you for long response 😊 .

My main purpose in here actually show the form and submit it.  
It actually looks like

I send a request a API and thats the response of the API.

```auto
{
    "htmlContent": "<!doctype html>\n<html lang=\"en\">\n<head>\n <title>iyzico Mock 3D-Secure Processing Page</title>\n</head>\n<body>\n<form id=\"iyzico-3ds-form\" action=\"https://sandbox-api.iyzipay.com/payment/mock/init3ds\" method=\"post\">\n <input type=\"hidden\" name=\"orderId\" value=\"mock12-0791572182721940iyziord\">\n <input type=\"hidden\" name=\"bin\" value=\"552879\">\n <input type=\"hidden\" name=\"successUrl\" value=\"https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/success/3\">\n <input type=\"hidden\" name=\"failureUrl\" value=\"https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/failure/3\">\n <input type=\"hidden\" name=\"confirmationUrl\" value=\"https://sandbox-api.iyzipay.com/payment/mock/confirm3ds\">\n <input type=\"hidden\" name=\"PaReq\" value=\"f00ad5a2-a580-4346-ba45-19647ca11bf0\">\n</form>\n<script type=\"text/javascript\">\n document.getElementById(\"iyzico-3ds-form\").submit();\n</script>\n</body>\n</html>",
    "status": "success",
    "errorCode": null,
    "errorMessage": null,
    "errorGroup": null,
    "locale": "tr",
    "systemTime": 1697558195590,
    "conversationId": "123456789"
}

```

Normally visualize should look like this

![resim](https://us1.discourse-cdn.com/getpostman/original/3X/4/9/49bdb8ec67f4bf5ac94215b839268cb52e64993d.png)

but it comes empty page

I use fixHtml function for getting html like this

```auto
<!doctype html>
<html lang="en">
<head>
    <title>iyzico Mock 3D-Secure Processing Page</title>
</head>
<body>
<form id="iyzico-3ds-form" action="https://sandbox-api.iyzipay.com/payment/mock/init3ds" method="post">
    <input type="hidden" name="orderId" value="mock12-7983036970477771iyziord" />
    <input type="hidden" name="bin" value="552879" />
    <input type="hidden" name="successUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/success/3" />
    <input type="hidden" name="failureUrl" value="https://sandbox-api.iyzipay.com/payment/iyzipos/callback3ds/failure/3" />
    <input type="hidden" name="confirmationUrl" value="https://sandbox-api.iyzipay.com/payment/mock/confirm3ds" />
    <input type="hidden" name="PaReq" value="9194771e-8fa8-4d6d-a7a9-840ec8b7c12f" />
</form>
<script type="text/javascript">
    document.getElementById("iyzico-3ds-form").submit();
</script>
</body>
</html>

```

I read the documentation of cheerio but it not actually helps me to visualize it.  
If you have any idea for visualizing i will be happy to hear

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 17, 2023, 4:43pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/9 "2023-10-17T16:43:55Z")

</div>

This seems to visualize ok on my machine.

It looks like its triggering the form and pulling the data from iyzipay.

![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/c/dc92fc7db8666a5539d9c2060c1078a8d9b0d709.png)

I didn’t realise that was possible. (Not sure you are meant to be able to do this).

I’m using the web client, not sure if this will work from the desktop client.

If you try and inspect the frame source, it takes you to the iyzpay mock.

> [https://sandbox-api.iyzipay.com/payment/mock/init3ds](https://sandbox-api.iyzipay.com/payment/mock/init3ds)

---

<div class="post-metadata">

**Author:** ![baha-bayar](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@baha-bayar](https://community.postman.com/u/baha-bayar)\
**Post date:** [October 17, 2023, 4:56pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/10 "2023-10-17T16:56:37Z")

</div>

what is your test script can you provide?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 17, 2023, 4:59pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/11 "2023-10-17T16:59:01Z")

</div>

On a side note, this isn’t really visualizing the HTML you posted, but showing you what is returned when the form is submitted.

I don’t think this will work from the desktop client, as I’m sure I’ve seen posts where it mentions that this is disabled as the desktop client uses your local browser for the Visualize feature.

I guess its different for the web client, as you can’t disable JavaScript otherwise the rest of the app wouldn’t work.

It’s a bit of a security risk having this pull in data from outside Postman, that you haven’t specifically sent a Post request to.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 17, 2023, 5:01pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/12 "2023-10-17T17:01:56Z")

</div>

> [@baha-bayar](#):
>
> what is your test script can you provide?

Using the HTML from the post you provided, it will work without the fixHTML code you had previously.

So its nothing more than…

```auto
const htmlContent = pm.response.json().data;
pm.visualizer.set(htmlContent);

```

I’m doing the same as @xk0der in that I’m using Postman Echo to return the HTML based on your example.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [October 17, 2023, 5:24pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/13 "2023-10-17T17:24:04Z")

</div>

I’ve just tested the desktop app and its not working there.

You can see if you inspect the visualization that its sat on your HTML code, which won’t show anything as the form elements are hidden.

Pretty sure that is expected behaviour. It should stay on the HTML that you provided to the visualizer, which as its showing hidden form data, shouldn’t show anything.

It’s not executing the JavaScript to submit the form to bring up the mock that you are expecting to see.

Saying that, you can use scripts in the HTML templates that you provide to the Visualizer, as I’ve used that a few times to reformat dates. So I don’t think JavaScript is completely disabled in the desktop version.

Not sure this should work from the web version either (but it does seem to at the moment).

Perhaps someone from Postman may be able to advise further on whether you are supposed to be able to do this or not.

---

<div class="post-metadata">

**Author:** ![baha-bayar](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@baha-bayar](https://community.postman.com/u/baha-bayar)\
**Post date:** [October 17, 2023, 5:30pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/14 "2023-10-17T17:30:24Z")

</div>

Thank you for the response. I didn’t realize there was a difference between the Web Postman and the desktop version. I believe that’s why it’s not working

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 16, 2023, 5:30pm UTC](https://community.postman.com/t/visualize-html-not-working/53257/15 "2023-11-16T17:30:55Z")

</div>

Closed on November 16, 2023, 5:30pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
