Skip to content
CodeKruPro

Build a URL and encode search text

Automation taskEasyAsked in: Capgemini, Wipro

A common warm-up question is: "What is the difference between a path parameter and a query parameter?" Here you build URLs with both, encode special characters such as spaces and &, and check what the server really received.

Build a URL and encode search text

01 · Read and understand requests

Recommended first: Tell an HTTP error from no response

Your goal: Build a URL and encode search text

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

The base URL identifies a service; the path identifies a resource. A query begins after ? and uses & between parameters. A space in a query is written as %20. An ampersand inside a value is written as %26, otherwise it starts a new parameter.

Your goals

  • Separate base URL, path and query.
  • Send spaces and reserved characters as intended data.

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. Send the search for John Doe. Before you send, look at the URL and separate the origin, the path, and the query after the question mark. A space in the search text is written as %20. Select that response.
  2. Read meta.total in that response. An empty data list can still be a successful search.
  3. Send the second search. %26 inside the query stands for an & that is part of the search text. Select that response.
  4. Copy both meta.total values. For the path, copy the resource path from the URL, the part before the question mark.
  5. Submit Answers.

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

  • Space and ampersand are encoded within the value.
  • Both totals are read from the actual responses.
  • The path is separated from the query.
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
  • Space and ampersand are encoded within the value.
  • Both totals are read from the actual responses.
  • The path is separated from the query.

Construct a query containing a literal +, then inspect which text the server searched.

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