Home > OS >  Thunderclient how to pass a response value to the next request
Thunderclient how to pass a response value to the next request

Time:09-03

I want to use [thunderclient] to test an http api.

The steps below are all working

  --------                                           ------------------ 
 |        |--1 -- Login with user   pass         -->|  Server          |
 |        |                                         |                  |
 |        |<-2 -- Login reply with access_token  ---|  if user pass ok |
 |        |                                         |                  |
 |        |--3 -- checkConfig-request with token -->|  check token     |
 | Client |                                         |                  |
 |        |<-4 -- Reply with payload             ---|  if token ok     |
  --------                                           ------------------ 

But currently i copy the value of access_token from step 2 into step 3 and then send the request manually.

This is the reply from step 2

{
  "access_token": "---best---kept---secret---",
  "expires_in": 300,
  "refresh_expires_in": 0,
  "token_type": "Bearer",
  "not-before-policy": 1626860494,
  "scope": ""
}

I want to use the value from access_token from the Login-Reply (2) pass it to a variable {{access_token_cc}} and then use this variable to pass the value of access_token as the Bearer Token in the checkConfig-request (3) (see screen)

Thunderclient_how_to_pass_a_variable

Question - how to use a variable?

I do not quite understand how to create a variable and assign a value to it. There is a video on youtube but the step to put the pieces together is to brief and not really explained.

CodePudding user response:

According to the documentation

Set the source of the variable to json.access_token

Determine which type of environment you want to store it to

  • Related