Make dynamic name text field in Postman

manoj picture manoj · Sep 22, 2014 · Viewed 36.7k times · Source

I'm using Postman to make REST API calls to a server. I want to make the name field dynamic so I can run the request with a unique name every time.

{
  "location":
  {
    "name": "Testuser2", // this should be unique, eg. Testuser3, Testuser4, etc
    "branding_domain_id": "52f9f8e2-72b7-0029-2dfa-84729e59dfee",
    "parent_id": "52f9f8e2-731f-b2e1-2dfa-e901218d03d9"
  }

}

Answer

MisterJames picture MisterJames · Oct 14, 2014

In Postman you want to use Dynamic Variables.

The JSON you post would look like this:

{
  "location":
  {
    "name": "{{$guid}}", 
    "branding_domain_id": "52f9f8e2-72b7-0029-2dfa-84729e59dfee",
    "parent_id": "52f9f8e2-731f-b2e1-2dfa-e901218d03d9"
  }

}

Note that this will give you a GUID (you also have the option to use ints or timestamps) and I'm not currently aware of a way to inject strings (say, from a test file or a data generation utility).