Edit XML body request before sending

I am doing something similar to what is described in this article:


except that I need to include one extra line in the body of my request. The extra line value will be dynamically calculated based on the value of the request body [BEFORE the extra line was added, think body signature ]
How do I do this?

Consider adding a Postman variable in your request body.

Any idea how to handle the recursive issue that comes from adding a postman variable {{bodySignature}} to the body?
I agree the variable could serve as a placeholder so I can inject my content before sending. However I need to calculate the signature of the body as if {{bodySignature}} was not in there. Are you suggesting I should start my script by making a copy of the Request.body and removing the variable?

Hi @ebioux,

Welcome to the community! :clap:

So, in order to perform this, you will need to make your request a Postman variable, whether it be global, environmental, or a collection variable.

Then when you’ve done that, you will have access to that variable in your pre-request section. There you can calculate your signature, then modify the variable to include the signature, or include the signature as a new variable in your request body.

So, what you would put in your request body section of the Postman Request is as follows:

{{requestBody}}

Or

{{requestBody}}
{{bodySignature}}

This of course depends on which method you do above, but when the request is sent, the variables will be replaced with those actual value(s), and you should get your desired behavior. If you know how you’re calculating your signature, I can show you an example script of how you would achieve this.

Best,
Orest