Open Source API Gateway

405 Method Not Allowed or 400 Bad Request: Request Does Not Fit the Generated API

Membrane API Gateway returns 405 Method Not Allowed or 400 Bad Request when the wsdl2openapi plugin, which exposes a SOAP service as a REST API, rejects a request before converting it to SOAP. The request does not fit the generated API.

The Error Response

The response contains the problem type https://membrane-api.io/problems/user and a link to this page. The type user means that the request caused the problem, not an internal failure of the gateway. Status, title and detail depend on the case:

405 Method Not Allowed

The title is Method not allowed and the detail is The requested path does not support GET. Allowed: POST. The Allow header of the response lists the allowed methods.

400 Invalid Query String

The title is Invalid query string and the detail is The query string could not be parsed. Check for duplicate or malformed parameters.

400 Invalid Field Name

The title is Invalid field name and the detail is A field name in the request body cannot be mapped to XML.

What the wsdl2openapi Plugin Does

The wsdl2openapi plugin reads a WSDL and offers each SOAP operation as a REST endpoint with a generated OpenAPI document. It converts JSON requests and query parameters into SOAP messages and the SOAP responses back into JSON. By default, operations are exposed with POST. Under operations, you can give each operation its own method and path. See WSDL to OpenAPI Converter and SOAP to REST Gateway.

api:
port: 2000
flow:
- wsdl2openapi:
wsdl: partner.wsdl
operations:
getPartner:
method: GET
path: /partners/{id}
api:
  port: 2000
  flow:
    - wsdl2openapi:
        wsdl: partner.wsdl
        operations:
          getPartner:
            method: GET
            path: /partners/{id}

Common Causes

The Wrong HTTP Method

The path belongs to an operation, but the request uses another method than the one exposed for it, for example GET for an operation that is exposed with the default POST.

A Duplicate or Malformed Query Parameter

For an operation that takes query parameters, the query string contains the same parameter name twice, as in ?id=7&id=8, or has a broken percent-encoding.

A Property Name That Is Not a Valid XML Name

A property name in the JSON request body is not a legal XML element name, for example because it starts with a digit or contains a space, as in {"1st name": "Ann"}. It cannot be mapped to an element of the SOAP message.

How to Fix It

  1. Open the generated OpenAPI document under /api-docs and use the method, path and parameters it describes.
  2. Send each query parameter once and percent-encode its value.
  3. Use only the property names defined in the request schema.
  4. As an operator, if an operation must be callable with another method, set method for it under operations.

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:

Tutorials with runnable examples:

← All Membrane error messages

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