Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation/Issue surrounding bru.runRequest()? #3908

Open
DevinKott opened this issue Jan 29, 2025 · 0 comments
Open

Documentation/Issue surrounding bru.runRequest()? #3908

DevinKott opened this issue Jan 29, 2025 · 0 comments
Assignees

Comments

@DevinKott
Copy link

DevinKott commented Jan 29, 2025

I'm trying to create a single request that does the following:

  1. In the Pre-Request script, it calls another request to "upload" data.
  2. Then, it runs it's own endpoint call to "list" the uploaded data.
  3. 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:

Image

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")}`)
@ganesh-bruno ganesh-bruno self-assigned this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants