How to get Dynamic values using Pre-Request Script and concatenate

Hello Dears,
Hope everyone doing well.
I have the requirement to get values dynamically.
Base URL: http://localhost:8080/identityiq/rest/identities
Example :
Body :

 "firstname": "Anand",
"lastname": "Thivari" 

But here above I need to pass one more required variable is “name”. And “name” should be like “firstname”.“lastname”
Ex . Anand.Thivari
But I want the “name” variable as dynamically assign when the request is sent to the server.
Likewise, “email” also posts dynamically.
Can anyone suggest how to resolve it?
Thanks in advance.!

  • Rakesh

Thank god, I resolved myself.

Method: POST
Base URL: http://localhost:8080/identityiq/rest/identities/
Body : json-raw

    "firstname" : "{{firstname}}",
    "lastname" : "{{lastname}}",
    "name" : "{{name}}",
    "email" : "{{email}}"

Pre-request Script:

var fname = "Aravind";
var lname = "Thivari";
var fullname = fname+"."+lname;
var email = fname+"";


Thanks and pls suggest to me if have any other way.

Hi @rakesh,

Instead of using the environment variable, you can also use, local variables if it is just a temporary thing.

For example,
pm.variables .set(“email”,email); // These are not direct visible like the environment variables, but of for a tempory thing it doessnt matter.

pm.collectionVariables .set(“email”,email); // This is visible in your collection tab

Hope this helps.