Nurlan Mirzayev Nurlan Mirzayev - 1 month ago 24
Javascript Question

Dynamic variables in Postman

In Postman official website in documentation Writing Tests I find that Postman has a few dynamic variables. My question about:


{{$guid}}:Adds a v4 style guid


this one. Can anybody explain me what kind of variable this one, and how we can use it in test scripts for API request.

Answer

GUID is the acronym for "Globally Unique Identifier". A GUID is mainly used to produce hexadecimal digits with groups separated by hyphens for uniqueness purposes, for example:

b3d27f9b-d21d-327c-164e-7fb6776f87b0

In postman you can use this to generate and send a random GUID to your api as required:

{
    "id": "{{$guid}}",
}

On Send would produce(with the random example above):

{
    "id": "b3d27f9b-d21d-327c-164e-7fb6776f87b0",
}