Postman flow, use variable for previous request in body

so i have the following postman flow:
Request #1: Select “id” variable from the response.
Request #2: I need to use the “id” from request #1 response, inside the body of request #2 dynamically, I searched through the web but couldn’t find any reasonable solution…

Is this the same request as?

Pre-request-script post take id and put on get request - :person_raising_hand: Help - Postman Community

Did you just create another account and ask the same question?

If not, then the same advice applies here.

This type of activity is covered in the Postman Learning Centre.

If you are new to Postman, then I would suggest a visit to the Learning Centre.

Overview | Postman Learning Center

Including the Postman Training links under “Resources”.


I would recommend the “Galaxy APIs 101” course first as it gets you used to the application features and GUI.

Then the “Galaxy Testing and Automation” course which teaches you how to assert the responses. It includes defining and using variables from responses and chaining requests.

No because I want to get a variable from a post, that’s easy, and then where I’m stuck is how to put the variable inside another post, not a get

It doesn’t really matter whether its a GET or POST request.

The only thing that really matters is whether its a query parameter or a JSON body.

Even then, that doesn’t really matter as in both scenarios, you save the variable from the initial Post request to a collection or environment variable then reference it using {{variableName}} either in the JSON body or the query param.

You can use the following link for more details on how to store and use variables.

Store and reuse values using variables | Postman Learning Center

The Galaxy Testing and Automation course has an example of this flow.

What you are trying to do is Postman basics, hence the advice to try those Learning Centre resources.

Thanks, all this time i thought my variable isn’t working but the problem is different, as soon as i input a variable in the body, the signature calculation script i use breaks… since it take the variable and not the value of the variable
is there any way to fix it?

script below:

var timestamp = (Math.floor(new Date().getTime() / 1000) - 10).toString();
postman.setGlobalVariable(“rapyd_request_timestamp”, timestamp);

var signature_salt = CryptoJS.lib.WordArray.random(12);
postman.setGlobalVariable(“rapyd_signature_salt”, signature_salt);

var body = ‘’;
if (JSON.stringify( !== ‘{}’ && !== ‘’ && typeof !==‘object’ ){
body = JSON.stringify(JSON.parse(;
var secret = pm.environment.get(‘rapyd_secret_key’);
var to_sign = request.method.toLowerCase() + request.url.replace(‘{{base_uri}}’,‘/v1’) + signature_salt + timestamp + pm.environment.get(‘rapyd_access_key’) + secret + body;

console.log("to_sign " + to_sign);
var rapyd_signature = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(to_sign, secret));
rapyd_signature = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(rapyd_signature));
console.log("rapyd_signature " + rapyd_signature);
postman.setGlobalVariable(“rapyd_signature”, rapyd_signature);

‫בתאריך יום ב׳, 23 באוק׳ 2023 ב-19:25 מאת ‪Mike Jones via Postman Community‬‏ <‪‬‏>:‬

Which variable are you having issue with?

At a glance, it might be the {{base_uri}}

You can only use {{variableName}} in certain places, like the URL and body.

Also it looks like you have wrapped the {{base_uri}} in quotes which means it will treat it as a string instead of the variable.

You also appear to be mixing the old postman method instead of using the recommended pm method in a few places (postman.setGlobalVariable for example instead of pm.globals).

On a side note, do you really need these to be global variables (available to all collections in Postman). They probably should be collection or ideally environment variables.

When posting code or JSON responses on the forum, please use the preformatted text option in the editor which stops everything from being aligned to the left (and also keeps the correct formatting for the quotes).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.