Asmerito
Asmerito

Reputation: 160

Postman- Use collection variable in request body

I have a problem with Postman, where I want to use collection variables inside the request body. According to postman documentation, all variables in postman GUI can be retrieved with double curly braces {{}}. But it does not work for me. If I move variables from collection to environment, everything is working OK, but as soon as I move the variable from the environment to collection, it starts throwing errors like this:

JSONError: Unexpected token 'U' at 1:1
Unrecognized token 'Backend': was expecting (JSON String, Number, Array, Object

This is my body:

{
    "name": {{BackendValidationPSName}},
    "groups": {{myBackendValidationRGuuids}}
}

Can anyone point me in the right direction? Tx.

Upvotes: 5

Views: 7826

Answers (2)

Asmerito
Asmerito

Reputation: 160

Solved. I was missing the "" in the collection variable value.

Upvotes: 1

Austin Jerry
Austin Jerry

Reputation: 161

The values have to be in double quotes

{
    "name": "{{BackendValidationPSName}}",
    "groups": "{{myBackendValidationRGuuids}}"
}

Upvotes: 11

Related Questions