Change request body in pre-request script

I am doing body level encryption in the pre-request script and want to the replace the entire reuqest body with encrypted data before sending the actual request

Hey @docking-module-geol4,
Welcome to the community :wave:
Is there anything, a question, or probably a hint as to where you’re trying to drive this discussion? Are you facing any issues with the pre-request script? We have some wonderful folks in the community who can help but make sure you mention what it is that you’re looking for.

1 Like

just provide a variable in place of request body:

{{requestBody}}

And modify this from pre-request script

pm.variable.set("requestBody", JSON.stringify( { "name":"test"} ))

1 Like

you can also modify it as :smiling_face_with_three_hearts:

pm.request.body='{"name":"age"}'

Let us if you would need any help :smiley:

2 Likes