MuleSoft · APIkit for REST
APIKIT:BAD_REQUEST
APIKIT: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.
Needs verificationLast reviewed
01Error text
Error type: APIKIT:BAD_REQUEST
HTTP status: 400
Response message: Bad request02Likely causes
- Unconfirmed: the request does not satisfy the rules of the API specification, such as a body, query parameter or header that fails validation.
- APIkit for REST automatically validates incoming requests against the API contract defined in RAML or OAS.
03How to fix it
- Read the full error description in the log to see which part of the request was rejected.
- Compare the failing request with the API specification the APIkit router uses, and correct whichever of the two is wrong.
- To control what the caller receives, add an On Error Propagate handler with the type
APIKIT:BAD_REQUESTthat sets the response body and anhttpStatusvariable of 400. The APIkit scaffolder can generate this baseline handler. - Adapt the handler if your API needs a custom status code or message.
iNotes
The APIkit router has attributes that change what it validates: queryParamsStrictValidation (validates that request query parameters are defined in the RAML file), headerStrictValidation (validates that request headers are defined in the RAML file or belong to a well-known set of headers) and disableValidations (disables validations of requests).
04Official documentation
→Related errors
- HTTP:BAD_REQUESTHTTP: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.
- APIKIT:UNSUPPORTED_MEDIA_TYPEAPIKIT:UNSUPPORTED_MEDIA_TYPE is the APIkit for REST error type that maps to HTTP status 415 with the response message "Unsupported media type". APIkit validates incoming requests against your RAML or OAS API specification, so compare the failing request with the specification.
- APIKIT:NOT_FOUNDAPIKIT:NOT_FOUND is the APIkit for REST error type that maps to HTTP status 404 with the response message "Resource not found". APIkit validates incoming requests against your RAML or OAS API specification, so compare the failing request with the specification.
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