Knowledgebase

Understanding Content Types and Serialisation Print

  • 0

How data is represented in transit.

WHAT A CONTENT TYPE DECLARES

The format of the body.

WHY IT MATTERS

The receiver parses according to it, and a mismatch produces confusing errors.

WHAT TO SEND

The header matching what you actually send.

WHAT THE COMMON TYPES ARE

Structured text, for most interfaces Form encoding, for simple submissions Multipart, for file uploads Plain text Binary formats, in performance-sensitive cases

WHAT ACCEPT HEADERS DO

Declare what the caller can handle.

WHAT CONTENT NEGOTIATION IS

The server choosing a format based on that.

WHY IT IS RARELY WORTH IT

Supporting several formats multiplies testing for little benefit.

WHAT TO DO INSTEAD

Support one, and document it.

WHAT TO BE CAREFUL WITH IN SERIALISATION

Numbers too large for the receiver's type Decimal precision lost in conversion Dates serialised inconsistently Character encoding

WHY LARGE NUMBERS SPECIFICALLY

Identifiers beyond a certain size lose precision in some languages, silently.

WHAT TO DO ABOUT IT

Send large identifiers as strings.

WHAT TO SPECIFY

The character encoding, explicitly.

WHAT TO TEST

Round-tripping awkward values: accented characters, very large numbers, empty values.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot