Membrane API Gateway returns an error when the transform plugin cannot apply its XSLT stylesheet to the message body. In the request flow, the client's body is the usual cause. In the response flow, the backend's body or the stylesheet is the cause.
The response contains the problem type https://membrane-api.io/problems/user and a link to this page. The status is 400 Bad Request in the request flow. In the response flow, the client receives 500 Internal Server Error, and in production mode the title is replaced by Internal Server Error. Title and detail depend on the case:
The title is Content not allowed in prolog of XML input. and the detail is Check for extra characters before the XML declaration <?xml ... ?>. The response also shows the beginning of the body.
The title is Content not allowed in trailing section of XML input. and the detail is Check for extra characters after the XML root element (after the final closing tag like </root>). The response also shows the end of the body.
The title is XML parsing failed and the detail contains the message of the XML parser.
The title is User error. and the detail is Error transforming message!, together with the exception and the flow.
The transform plugin applies an XSLT stylesheet to the XML body of a request or response and replaces the body with the result:
api:
port: 2000
flow:
- request:
- transform:
xslt: convert-request.xslt
- response:
- transform:
xslt: convert-response.xslt
target:
url: https://api.predic8.de
api:
port: 2000
flow:
- request:
- transform:
xslt: convert-request.xslt
- response:
- transform:
xslt: convert-response.xslt
target:
url: https://api.predic8.de
The body has characters before the XML declaration or root element, for example a byte order mark, whitespace before <?xml, or a body that is not XML at all, such as JSON, HTML or plain text.
The body has characters after the closing tag of the root element, for example a second root element or appended text.
The body contains an unclosed tag, a missing quotation mark or an invalid character.
The stylesheet fails at runtime, for example through an xsl:message terminate="yes", a type error or a failed document() call.
The body cannot be read or decoded, for example because of a broken Content-Encoding or an invalid XOP package.
transform only runs on XML responses.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: trueconfiguration: production: true
Add the configuration document to your apis.yaml and separate it from the APIs with ---.
Configuration reference:
Tutorials with runnable examples:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.