S
S
Sergey2019-12-03 15:28:44
phpstorm
Sergey, 2019-12-03 15:28:44

Is the variable not set in the HTTP client?

There is a code:

POST {{host}}login
Cache-Control: no-cache
Content-Type: application/json

{
    "login": {{users_client_login}},
    "password": {{users_client_password}}
}

> {%
client.global.set("auth_token", response.body.token);
%}

###

GET {{host}}user?api_token={{auth_token}}
Accept: application/json
Cache-Control: no-cache
###

I receive a token and I need to pass it further in the next request.
client.global.set - works fine, if I write get then I will get a token. But if it is called by {{auth_token}}, then the variable will be undefined.
If you run it again, then {{auth_token}} will be what was set the previous time.
That is, the variable is set when the file is launched and is not overwritten during query execution.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question