top of page

Which Header Describes What You Send, and Which Describes What You Want Back?

Oct 25
3 min read
Content-Type vs Accept: Review an API Contract: Describe outgoing content; Request a response type; Inspect actual content.

An integration sends a JSON document but receives an HTML error page. The developer points to an Accept header requesting JSON and assumes the server must therefore have returned JSON. The parser fails, and the useful evidence disappears behind a generic exception. The missing step is to distinguish a format preference from the representation that actually arrived.


A clear media-type contract helps contributors explain both successful and failed exchanges. It also gives an operations reviewer a concrete way to check whether a dashboard or automation can recover when the response differs from the happy-path example.


Label both directions of the exchange


Draw two rows in the integration brief: request sent to the API, and response returned to the client. For each row, record whether there is content, its expected media type, and the parser that will handle it.


RFC 9110 defines Content-Type as representation metadata. Its Accept section describes a client's response media-type preferences. Setting Accept does not transform outgoing bytes, and an intended format is not evidence of the actual response content.


Use the provider's current endpoint documentation to fill in the supported request and response types. Do not infer a contract solely from a filename suffix, a sample pasted into a ticket, or another endpoint on the same service.


An illustrative two-direction card


For a synthetic report-submission endpoint, the card might state: request content is a JSON object with a report identifier; the request declares application/json; the client requests a JSON response; the successful response contains a receipt identifier.


The failure contract needs its own row. Specify how the client handles a structured API error, an unexpected media type, an empty response where the endpoint allows one, and a connection failure. Those cases should not all be routed through the same JSON parser without checking the exchange.


Review the bytes as well as the label


In a controlled test, compare the outgoing serialization with the declared request Content-Type. A label cannot make malformed or differently encoded content valid. Keep the synthetic payload small enough that a reviewer can inspect it without exposing business data.


Then capture the response status, Content-Type, and a suitably redacted or synthetic content sample. Verify that the actual response matches the endpoint contract before describing the integration as successful.


If an intermediary returns an HTML diagnostic page, preserve a bounded diagnostic note rather than rendering that page inside the application as trusted content. A useful user-facing message can explain that the expected service response was unavailable while the technical log retains the information needed for investigation.


Make parsing failure distinguishable


Give format mismatch and invalid structured content different internal classifications. “Unexpected response type” points investigators toward routing, authentication, intermediaries, or provider behavior. “Expected type but invalid content” points to a different contract failure.


These labels are a proposed diagnostic convention, not standardized HTTP status meanings. Adopt names that fit the team's logging system and avoid including credentials or unrestricted response bodies in the record.


Build a compact response fixture


Create synthetic responses for four cases: the documented success shape, the documented error shape, a different media type, and malformed content carrying the expected media type. If the endpoint documents a legitimate empty response, include that as a fifth case.


For each fixture, write the expected parser decision, user message, and workflow state. A failed parser must not silently become an empty successful report. An empty list is a business value; a response the client could not interpret is an unresolved technical result.


Also check that the failure path preserves the user's work where applicable. Someone submitting a long project brief should not have to recreate it simply because the response did not match the contract.


Check the provider behavior without guessing


If a requested format is not supported, inspect the provider's documented behavior and an authorized test result. Record what the endpoint actually does instead of assuming that every service negotiates formats in the same way.


When discussing the issue with a partner, share the endpoint operation, redacted request headers, timestamp, observed response type, and a minimal synthetic reproduction. That packet is more useful than saying “JSON is broken.”


Keep the handoff explicit


Store the two-direction contract card with the integration tests and assign an owner for reviewing provider changes. Make the successful response and failure cases visible to the contributor maintaining the workflow.


The integration is ready when the team can explain what it sends, what it asks to receive, what it actually received, and how it behaves when those expectations diverge.


Continue with Should an Integration Decide What to Do by Reading an Error Sentence? for the related planning decision.


The published FutureOS introduction describes the project as being in prelaunch. Use this guide to prepare a concrete project discussion; it does not announce an available FutureOS feature.



Prepared with AI assistance. Primary sources checked on October 25, 2026. Examples and procedures are illustrative editorial guidance, not FutureOS product announcements or an independently reviewed assessment.

Recent Posts

See All

Comments


bottom of page