Skip to content
CodeKruPro

Use variables and find the wrong final value

Automation taskEasy-MediumAsked in: Capgemini, Infosys

A practical follow-up: "Your request goes to the wrong server. How do you debug it in Postman?" In this lesson you use variables and then read the final request (with all variables replaced by their values) to find which value was really sent.

Use variables and diagnose the wrong resolved value

02 · Build reusable requests and investigate results

Recommended first: Organize your first Postman collection

Your goal: Use variables and diagnose the wrong resolved value

Follow one request at a time. Send it yourself, then select that response before you answer.

  1. 1Send requests
  2. 2Submit answers

Start here: sign in to practise.

Jump to practice

What you will learn

Continue with Beginner API Lab from the previous lesson. A variable stores a value under a name. Postman replaces {{name}} before sending. Changing the saved value changes the outgoing URL without rewriting the request.

Your goals

  • Send the same kind of request to user 1 and user 99.
  • Tell a saved name apart from the URL that was sent.

Before you start

Read the previous lesson first if you have not already. This course does not require programming.

Practice setup

These requests use the public TestKru teaching API. No workspace is needed unless a step says so. Leave the body empty for GET, HEAD and OPTIONS. Example people and emails are fictional. Changes to /api/users are simulated and are not saved.

Follow these steps

  1. Open Beginner API Lab in Postman. On its Variables tab add baseUrl with value https://testkru.com/api and userId with value 1. Save.
  2. Add a request named Variable user with URL {{baseUrl}}/users/{{userId}}, method GET, No Auth and no body. Send it and inspect the resolved request URL in the Postman Console.
  3. Change the collection userId value to 99, save and send the same request again. Check the resolved URL and response. Avoid environment variables with the same names for this first exercise.
  4. Reproduce both resolved URLs in the course console and select their responses. Answer which value the server received.
  5. Export the updated collection as v2.1 JSON with userId still 99. Paste it in the collection field and submit. Keep the file and collection for the later authentication and sharing lessons.

Investigate before concluding

First record the actual result for each case. Compare the body, headers and later state with the stated contract. Keep an observation separate from a prediction; use the model answer only after making your own attempt.

What to keep as evidence

  • Both user ids are requested.
  • The statuses are copied from the selected responses.
  • The sent URL is distinguished from a saved name.
References for this lesson

Finish this assignment

Select each named response with Use this response. Answer from those responses or the transcript on this page. Click Submit Answers. Your score is the percentage of checks that passed. Core checks are required to finish. Extra evidence checks are labelled. A saved 100/100 means every check passed. Continue opens the next lesson you can submit.

If something goes wrong
  • Change one part of the request at a time. If a check needs attention, read the note under it and compare it with the response you selected.
Self-review and independent variation
  • Both user ids are requested.
  • The statuses are copied from the selected responses.
  • The sent URL is distinguished from a saved name.

Predict what happens if {{baseUrl}} is left unresolved. The client may reject it before any HTTP response.

Automatic checks verify the requests and answers configured for this lesson. The self-review is for your own reasoning. A score is not a certificate.

Open API reference

Practise and save your evidence

The lesson is public. Sign in to send requests and save progress. You will return to this lesson.

Sign in to practiseCreate an account