Open Source API Gateway

400 Bad Request: Request Body Could Not Be Decoded

Membrane API Gateway returns 400 Bad Request with the title Request body could not be decoded when the soap-2-rest-gateway plugin cannot decompress the request body with the Content-Encoding the client declared.

The Error Response

The response contains the status 400, the title Request body could not be decoded, the problem type https://membrane-api.io/problems/user/body-decoding and a link to this page. The type user means that the client caused the problem. The extra field contentEncoding names the encoding that failed. It is also sent in production mode.

Common Causes

The Body Is Not in the Declared Format

The request is labelled Content-Encoding: gzip, deflate or br, but the body is not in that format, for example plain JSON labelled as gzip.

The Compressed Body Is Truncated or Corrupt

The compressed stream ends early or is damaged. A gzip body cut off inside its trailer is reported as EOFException.

The Connection Broke During the Upload

Because the body has a Content-Encoding, a connection that breaks while the body is being read is reported as a decoding failure too.

How to Fix It

  1. Compress the body with the encoding named in Content-Encoding, or leave the header out for an uncompressed body.
  2. Make sure the whole compressed body is sent. In development mode, the detail field quotes the decoder's error.

Membrane decodes only gzip, deflate and br. Bodies with other Content-Encoding values are passed through without decoding and do not cause this error.

Hide Details in Production

By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:

configuration:
production: true
configuration:
  production: true

Add the configuration document to your apis.yaml and separate it from the APIs with ---.

Related Documentation

Configuration reference:

← All Membrane error messages

Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.