Skip to content
CodeKruPro

Separate JSON syntax from validation rules

12/32

02 · Build reusable requests and investigate results

Recommended first: Use variables and diagnose the wrong resolved value

Your goal: Separate JSON syntax from validation rules

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

Valid JSON can still contain the wrong kind of data. Parsing answers whether the text is readable JSON; field validation answers whether its data satisfies a rule.

Your goals

  • Compare valid and malformed JSON.
  • Record a wrong-type value accepted by a legacy endpoint.

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 valid echo request. Check the quotes, commas and braces, then select its response. It echoes data. It does not save a user.
  2. Send the broken text exactly as the step shows it. Select that response and read the message.
  3. Send the users request whose age is the text twenty, with a valid name and email. Select that response.
  4. Copy the status of the broken request and the age value that came back. Then choose which layer should reject a wrong type.
  5. Submit Answers. The simulated /api/users API and the later customer API are different.

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

  • Malformed JSON and wrong-type JSON are different tests.
  • Other inputs stay valid to avoid masking the age probe.
  • Observed legacy behavior is not silently replaced by an ideal rule.
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
  • Malformed JSON and wrong-type JSON are different tests.
  • Other inputs stay valid to avoid masking the age probe.
  • Observed legacy behavior is not silently replaced by an ideal rule.

Send numeric age 25 and compare its JSON type with "25".

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