I want to create a dynamic requestbody through a pre-requisite script. I want that script to extract the headers from the csv datafile and add them to the requestbody. I want to do this so that my code can be as reusable a possible.
You could make use of the this technique described by @vdespa in his video:
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: