Skip to content
CodeKruPro

Observe how methods behave instead of assuming

Automation taskEasyAsked in: Capgemini, Coupa, Infosys, TCS

"What is the difference between PUT and PATCH?" is one of the most asked API questions. In this lesson you send each method to a real API and watch what the server does, so your answer comes from what you saw.

Observe methods instead of assuming they behave alike

01 · Read and understand requests

Recommended first: Build a URL and encode search text

Your goal: Observe methods instead of assuming they behave alike

Type each request yourself. This lesson shows the method, URL, headers and body. It does not fill the console.

  1. 1Send requests
  2. 2Submit answers

Start here: sign in to practise.

Jump to practice

What you will learn

GET asks for data. HEAD asks for the headers without a body. OPTIONS asks how the server can be contacted. PUT on the collection URL is a different request from PUT on one user.

Your goals

  • Send GET, HEAD, OPTIONS and a method the collection does not allow.
  • Record the status and body you actually received.

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 GET https://testkru.com/api/users with an empty body. Select that response and notice whether the body is a list.
  2. Send the same URL with method HEAD and an empty body. Select that response. Compare the status with GET and look at whether the body is empty.
  3. Send the same URL with method OPTIONS and an empty body. Open the response headers and look for a header named Allow.
  4. Send PUT https://testkru.com/api/users. This is the collection URL, not /api/users/1. Select that response and read the status.
  5. Copy the four statuses. Choose whether the Allow header was present, then 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

  • Each method is sent separately.
  • HEAD is not given an invented body.
  • 405 is read as a method result, not as a missing user.
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
  • Each method is sent separately.
  • HEAD is not given an invented body.
  • 405 is read as a method result, not as a missing user.

Later, compare PUT /api/users with PUT /api/users/1 and write down which URL the 405 belongs to.

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