You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a single request that does the following:
In the Pre-Request script, it calls another request to "upload" data.
Then, it runs it's own endpoint call to "list" the uploaded data.
Assert is used to check the response for certain values.
Both requests take a header which I have set to a (collection) environment variable called UserId: UserId: {{UserId}}.
I.E. I essentially do the following, in the Pre-Request Script:
const user = generateId();
bru.setEnvVar("UserId", user); // Set the ID I just generated to be used for the runRequest()
const uploadResp = await bru.runRequest('Upload/Success/Success Request');
req.setHeader("UserId", user); // Set my own ID to the same
This does not work. It seems that the Upload/Success/Success Request request that I call uses the previous value of the {{UserId}} environment variable when running. Is this intended?
It was weird to figure out since the {{UserId}} environment variables was updated after checking, but just not when the request was running.
More information:
Logs:
Request 1:
const userId = genGUID();
console.log(`[REQ 1] We generated: ${userId}`)
bru.setEnvVar("UserId", userId);
console.log(`[REQ 1] Environment Variable Set To: ${bru.getEnvVar("UserId")}`)
const first = await bru.runRequest('Upload/Success/Successful Request');
const second = await bru.runRequest('Upload/Success/Successful Request');
console.log(first);
console.log(second);
console.log(`[REQ 1] Req 2 calls finished, we still have the value: ${bru.getEnvVar("UserId")}`)
req.setHeader("UserId", kmmpUserId);
Request 2:
console.log(`[REQ 2] Environment Variable Set To: ${bru.getEnvVar("UserId")}`)
The text was updated successfully, but these errors were encountered:
I'm trying to create a single request that does the following:
Both requests take a header which I have set to a (collection) environment variable called
UserId
:UserId: {{UserId}}
.I.E. I essentially do the following, in the Pre-Request Script:
This does not work. It seems that the
Upload/Success/Success Request
request that I call uses the previous value of the{{UserId}}
environment variable when running. Is this intended?It was weird to figure out since the
{{UserId}}
environment variables was updated after checking, but just not when the request was running.More information:
Logs:
Request 1:
Request 2:
The text was updated successfully, but these errors were encountered: