{"record":{"id":"3c34fbda5443f2d6","repo":"flowable/flowable-engine","slug":"either-eventdefinitionid-or-eventdefinitionkey-is","errorCode":null,"errorMessage":"Either eventDefinitionId or eventDefinitionKey is required.","messagePattern":"Either eventDefinitionId or eventDefinitionKey is required\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-event-registry-rest/src/main/java/org/flowable/eventregistry/rest/service/api/runtime/EventInstanceCollectionResource.java","lineNumber":122,"sourceCode":"        if (eventDefinition == null) {\n            throw new FlowableObjectNotFoundException(\"No event definition found\");\n        }\n\n        ChannelModel channelModel = null;\n        if (StringUtils.isNotEmpty(request.getChannelDefinitionId())) {\n            channelModel = repositoryService.getChannelModelById(request.getChannelDefinitionId());\n        } else if (StringUtils.isNotEmpty(request.getTenantId())) {\n            channelModel = repositoryService.getChannelModelByKey(request.getChannelDefinitionKey(), request.getTenantId());\n        } else {\n            channelModel = repositoryService.getChannelModelByKey(request.getChannelDefinitionKey());\n        }\n\n        eventRegistry.eventReceived((InboundChannelModel) channelModel, request.getEventPayload().toString());\n    }\n\n    protected void validateRequestParameters(@RequestBody EventInstanceCreateRequest request) {\n        if (request.getEventDefinitionId() == null && request.getEventDefinitionKey() == null) {\n            throw new FlowableIllegalArgumentException(\"Either eventDefinitionId or eventDefinitionKey is required.\");\n        }\n\n        int paramsSet = ((request.getEventDefinitionId() != null) ? 1 : 0) + ((request.getEventDefinitionKey() != null) ? 1 : 0);\n        if (paramsSet > 1) {\n            throw new FlowableIllegalArgumentException(\"Only one of eventDefinitionId or eventDefinitionKey should be set.\");\n        }\n\n        if (request.getChannelDefinitionId() == null && request.getChannelDefinitionKey() == null) {\n            throw new FlowableIllegalArgumentException(\"Either channelDefinitionId or channelDefinitionKey is required.\");\n        }\n\n        paramsSet = ((request.getChannelDefinitionId() != null) ? 1 : 0) + ((request.getChannelDefinitionKey() != null) ? 1 : 0);\n        if (paramsSet > 1) {\n            throw new FlowableIllegalArgumentException(\"Only one of eventDefinitionId or eventDefinitionKey should be set.\");\n        }\n    }\n}\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry-rest/src/main/java/org/flowable/eventregistry/rest/service/api/runtime/EventInstanceCollectionResource.java#L104-L140","documentation":"REST request validation in EventInstanceCollectionResource.validateRequestParameters: the create-event-instance body carries neither eventDefinitionId nor eventDefinitionKey, so the engine cannot determine which event definition the instance belongs to.","triggerScenarios":"POSTing an EventInstanceCreateRequest JSON body with an empty payload for both eventDefinitionId and eventDefinitionKey fields.","commonSituations":"Omitting the fields from the JSON body; field-name typos that deserialize to null; building the request programmatically without setting either field.","solutions":["Set either eventDefinitionId or eventDefinitionKey in the request body.","Verify JSON field names match EventInstanceCreateRequest properties exactly.","Validate the body client-side before sending.","Catch FlowableIllegalArgumentException and return a 400 with guidance."],"exampleFix":"// before\n{ \"channelDefinitionKey\": \"ch\", \"eventPayload\": {} }\n// after\n{ \"eventDefinitionKey\": \"myEvent\", \"channelDefinitionKey\": \"ch\", \"eventPayload\": {} }","handlingStrategy":"validation","validationCode":"if (req.getEventDefinitionId() == null && req.getEventDefinitionKey() == null) {\n    throw new IllegalArgumentException(\"Set eventDefinitionId or eventDefinitionKey\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    createEventInstance(req);\n} catch (FlowableIllegalArgumentException e) {\n    logger.error(\"Invalid event instance request: {}\", e.getMessage());\n}","preventionTips":["Always set exactly one of eventDefinitionId/eventDefinitionKey","Match JSON property names to the request class","Validate request bodies before sending"],"tags":["rest","validation","bad-request"],"backgroundTag":"missing-required-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}