Sobes.tech
Middle

What data formats can be transmitted in the request body in REST?

sobes.tech AI

Answer from AI

In REST, data in the request body is usually transmitted in the following formats:

  • JSON (application/json) — the most common format for exchanging structured data.
  • XML (application/xml or text/xml) — used less frequently, but still encountered in some systems.
  • Form data (application/x-www-form-urlencoded) — form data, often used when submitting from HTML forms.
  • Multipart/form-data — for transmitting files and form data simultaneously.

The choice of format depends on the API requirements and the type of data being transmitted. For example, JSON is preferred for transmitting complex structures.

Example of a request header and body with JSON:

POST /api/users HTTP/1.1
Content-Type: application/json

{
  "name": "Иван",
  "age": 30
}
What data formats can be transmitted in the request… - sobes.tech