# JSON request body with html content (from local file)

**URL:** <https://community.postman.com/t/json-request-body-with-html-content-from-local-file/32890>\
**Category:** Help Hub\
**Created:** [February 23, 2022, 11:09pm UTC](https://community.postman.com/t/json-request-body-with-html-content-from-local-file/32890 "2022-02-23T23:09:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![4rk](https://avatars.discourse-cdn.com/v4/letter/4/9de053/32.png) [@4rk](https://community.postman.com/u/4rk)\
**Post date:** [February 23, 2022, 11:09pm UTC](https://community.postman.com/t/json-request-body-with-html-content-from-local-file/32890/1 "2022-02-23T23:09:10Z")

</div>

Hi,  
I just started working with postman and wanted to see if I could get some help with constructing the POST request body.

My sample request body (JSON) is

{  
“id”: “correlation\_id”  
“data”: “HTML\_STRING”  
}

As I understand we’d need to escape the special characters in HTML\_STRING. What would be the best way to achieve loading the html content from file and having it as a part of the request as shown above, in Postman? Do I need to get the escaped content with some external script/online tool first before I formulate the request and then POST to my API ?

---

<div class="post-metadata">

**Author:** ![sahuvikramp](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sahuvikramp/32/10828_2.png) [@sahuvikramp](https://community.postman.com/u/sahuvikramp)\
**Post date:** [February 24, 2022, 4:19pm UTC](https://community.postman.com/t/json-request-body-with-html-content-from-local-file/32890/2 "2022-02-24T16:19:06Z")

</div>

Hello @4rk, Welcome to the community 🎉

There are two options:

1. If you are writing an external script for creating a file, I would suggest escaping the special characters and then putting the HTML content in the file.
2. you can use postman’s pre-request script for escaping the special characters in HTML content.

To use the HTML content as a part of API request:

1. Create a [data file](https://learning.postman.com/docs/running-collections/working-with-data-files/) with **id and data**
2. Iterate the file and [access the value](https://learning.postman.com/docs/running-collections/working-with-data-files/#accessing-data-file-values) from the file using `pm.iterationData.get("data")`
3. Set the environment/global/collection [variable](https://learning.postman.com/docs/sending-requests/variables/) after getting data from file.
4. Use [Dynamic variable](https://learning.postman.com/docs/writing-scripts/script-references/variables-list/) for assign value within JSON body.

I hope this works for you.

Cheers 🪄

---

<div class="post-metadata">

**Author:** ![4rk](https://avatars.discourse-cdn.com/v4/letter/4/9de053/32.png) [@4rk](https://community.postman.com/u/4rk)\
**Post date:** [February 27, 2022, 12:30pm UTC](https://community.postman.com/t/json-request-body-with-html-content-from-local-file/32890/3 "2022-02-27T12:30:41Z")

</div>

> - Create a [data file](https://learning.postman.com/docs/running-collections/working-with-data-files/) with **id and data**

Here the data, unless is escaped in the json/csv, does not seem valid. Doesn’t that necessitate that extra step to escape the data content first? Also, another example of the content I might send, on a different endpoint, is an email (headers with plain/html content), so not exactly just HTML. My apologies, if that would change the context and content of your original answer. I thought they could be handled in the same fashion.
