MuleSoft · HTTP Connector

HTTP:BAD_REQUEST

Short answer

HTTP:BAD_REQUEST means the server could not understand the request the HTTP Request operation sent because its syntax was invalid (HTTP 400). Log the outgoing request, compare it with what the server expects, and correct the body, headers or parameters.

VerifiedLast verified

01Error text

MuleSoft error
Error type: HTTP:BAD_REQUEST

02Likely causes

  • The server cannot understand the request due to invalid syntax. The docs give a header that exceeds the maximum size as an example.
  • By default, HTTP Connector raises an error for any response with a status code of 400 or above.

03How to fix it

  1. Turn on HTTP wire logging to see the exact request and response: in log4j2.xml, enable the logger org.mule.service.http.impl.service.HttpMessageLogger at DEBUG level.
  2. Compare the logged request with the server's API contract, then correct the body, headers, query parameters or URI parameters on the HTTP Request operation.
  3. Read the response body in the wire log. Most servers say which part of the request was invalid.
  4. Handle the failure with an error handler of type HTTP:BAD_REQUEST if the flow should respond to the caller in a controlled way.

iNotes

HTTP Connector adds a Host header that includes the default port (80 or 443), and the docs note that some servers and web application firewalls reject it. You can set the Host header yourself without the port, or set -Dmule.http.connector.omitDefaultPortInHostHeader=true (Mule 4.5 and later, connector 1.10.3 and later).

04Official documentation

Test every fix in a non-production environment before you apply it to production. See how entries are verified.

More for MuleSoft work:Open MuleSoft jobsMuleSoft rates and salariesHire a senior MuleSoft developer

The iPaaS Brief

Subscribe to The iPaaS Brief.

The iPaaS newsletter for the people who run integrations. From iPaaS Group.

Free. You finish on theipaasbrief.com and confirm by email.