Skip to main content

unsupported_media_type

HTTP 415, type invalid_request_error.

The request body was sent without a format the API reads.

Why it happened​

Today this code answers a request with a body and NO Content-Type header, or one whose Content-Type names a format the API has no reader for. A JSON body sent as text/plain does not answer this code today, and what it does answer depends on the endpoint: some read the body anyway and accept the request, and others report its fields missing as parameter_missing. Neither is a guarantee. Send JSON as application/json in every case. A body that is declared as JSON and does not parse is malformed_request instead.

How to fix it​

Send the body as JSON with Content-Type: application/json.

Retrying: retry only after fixing the Content-Type header, to application/json. This request is refused before its Idempotency-Key is claimed, so send the corrected request with the same Idempotency-Key.