MuleSoft · HTTP Connector
HTTP:BAD_REQUEST
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
Error type: HTTP:BAD_REQUEST02Likely 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
- Turn on HTTP wire logging to see the exact request and response: in
log4j2.xml, enable the loggerorg.mule.service.http.impl.service.HttpMessageLoggeratDEBUGlevel. - 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.
- Read the response body in the wire log. Most servers say which part of the request was invalid.
- Handle the failure with an error handler of type
HTTP:BAD_REQUESTif 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
→Related errors
- APIKIT:BAD_REQUESTAPIKIT:BAD_REQUEST is the APIkit for REST error type that maps to HTTP status 400 with the response message "Bad request". APIkit validates incoming requests against your RAML or OAS API specification, so compare the failing request with the specification.
- HTTP:NOT_FOUNDHTTP:NOT_FOUND means the HTTP Request operation received a 404 response because the server could not find the requested resource. Check the URL shown in the error description, then correct the request or handle the error type in an error handler.
- HTTP:UNAUTHORIZEDHTTP:UNAUTHORIZED means the server rejected the HTTP Request operation because authentication failed or was not provided (HTTP 401). Send the credentials the server expects, and handle the error type if a rejected call is something the flow should survive.
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