# How can I create a dynamic requestbody using a pre-requisite script?

**URL:** <https://community.postman.com/t/how-can-i-create-a-dynamic-requestbody-using-a-pre-requisite-script/50611>\
**Category:** Help Hub\
**Tags:** pre-request, pre-request-script, request-body, dynamic-request\
**Created:** [August 16, 2023, 8:35am UTC](https://community.postman.com/t/how-can-i-create-a-dynamic-requestbody-using-a-pre-requisite-script/50611 "2023-08-16T08:35:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [August 16, 2023, 11:00am UTC](https://community.postman.com/t/how-can-i-create-a-dynamic-requestbody-using-a-pre-requisite-script/50611/2 "2023-08-16T11:00:33Z")

</div>

Hey @sergeasmar 👋

Welcome to the Postman community! :postman:

You could make use of the this technique described by @vdespa in his video:

[![](https://img.youtube.com/vi/hSX7Dcjy000/maxresdefault.jpg "How to build request body with JavaScript in Postman") ](https://www.youtube.com/watch?v=hSX7Dcjy000)

That would allow you to create the body the in the pre-request script and use that as the payload. You can you the `pm.iterationData.get('header_name')` function in the dynamic request body to get those values from the data file.

There was also this from @odanylewycz that might be useful too:

> [@How To Create Dynamic Request Body in JSON and XML](https://community.postman.com/t/how-to-create-dynamic-request-body-in-json-and-xml/19730):
>
> Anyone ever find it difficult to customize a request body in Postman? From my research of the forum, it looks like a commonly asked question around here! It’s actually quite easy, and in this video, I demo how you can make a dynamic request body for both json and xml using a pre-request script! Great way to prep for Postman Galaxy! Hope you all find it helpful! [[How to Create a Dynamic Request Body // Postman Pointers] ](https://www.youtube.com/watch?v=jDbikYFHT34)

---

_[View the full topic](https://community.postman.com/t/how-can-i-create-a-dynamic-requestbody-using-a-pre-requisite-script/50611)._
