Skip to content
CodeKruPro

Request Content-Type versus response preferences

Automation taskEasy-MediumAsked in: Capgemini

Interviewers ask: "What is content negotiation?" (the client and the server agree on a data format) or "Your POST gets 415. Why?" (415 means the server does not support the format of the body). In this lesson you send bodies with and without the right Content-Type, ask for formats with Accept, and see how the server answers each case.

Distinguish request Content-Type from response preferences

01 · Read and understand requests

Recommended first: Rebuild a browser request using Network and cURL

Your goal: Distinguish request Content-Type from response preferences

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

You have already read response headers and rebuilt an Accept header. Now compare both message directions. Content-Type labels the body in that particular message. Accept expresses the response format the client prefers; the server contract decides what is supported.

Your goals

  • Send JSON with explicit request format and response preference.
  • Explain which body each header describes.

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. Prepare POST /api/echo with the supplied JSON body. Add both Content-Type: application/json and Accept: application/json in Headers.
  2. Before sending, identify the body you are labelling with Content-Type and the response format you are requesting with Accept.
  3. Send and select the response. Inspect its Content-Type separately from your outgoing Content-Type.
  4. Answer the two direction questions and submit. Echo does not prove this API supports every Accept value.

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

  • Header direction is correct.
  • Equivalent body values are compared.
  • Legacy and strict expectations are separated.
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
  • Header direction is correct.
  • Equivalent body values are compared.
  • Legacy and strict expectations are separated.

Ask for JSON while sending a JSON POST: explain the independent roles of the two headers.

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