Recipe

Debug a 422 validation error

A 422 means your request parsed but a value failed a rule. The envelope tells you exactly which: error.code names the rule, error.param names the field. This recipe maps the common codes to their fixes.

2 min read

422Validation failed
error.paramThe bad field
error.codeThe rule

Read the envelope

Do not guess. The error envelope pinpoints the problem.

{
  "error": {
    "type": "invalid_request_error",
    "code": "consent_required",
    "message": "fields.consent must equal \"yes\".",
    "param": "fields.consent"
  }
}

Map code to fix

Common enquiry-submission codes:

codeFix
consent_requiredSend fields.consent: "yes"
invalid_emailCorrect fields.email
form_requiredSet the form key
payload_too_largeTrim fields under 16 KiB
invalid_deptUse a valid dept or omit it

Do not retry blindly

A 422 is deterministic — the same request will fail again. Fix the field, then resend. See Retrying failed requests.

Frequently asked questions

Why 422 and not 400?

A 400 means the body could not be parsed at all. A 422 means it parsed fine but a value broke a business rule — error.param tells you which value.

Can I get multiple errors at once?

The envelope reports the first failing field. Fix it and resend; if another field is also wrong, you will get its error next.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.