{"record":{"id":"c1348968a10c67a2","repo":"flowable/flowable-engine","slug":"error-converting-request-body-to-restvariable-inst","errorCode":null,"errorMessage":"Error converting request body to RestVariable instance","messagePattern":"Error converting request body to RestVariable instance","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":409,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/PlanItemInstanceVariableResource.java","lineNumber":98,"sourceCode":"            @ApiParam(name = \"variableName\") @PathVariable(\"variableName\") String variableName, HttpServletRequest request) {\n\n        PlanItemInstance planItem = getPlanItemInstanceFromRequest(planItemInstanceId);\n\n        RestVariable result = null;\n        if (request instanceof MultipartHttpServletRequest) {\n            result = setBinaryVariable((MultipartHttpServletRequest) request, planItem.getId(), CmmnRestResponseFactory.VARIABLE_PLAN_ITEM, false,\n                    false, RestVariable.RestVariableScope.LOCAL, createVariableInterceptor(planItem));\n\n            if (!result.getName().equals(variableName)) {\n                throw new FlowableIllegalArgumentException(\"Variable name in the body should be equal to the name used in the requested URL.\");\n            }\n\n        } else {\n            RestVariable restVariable = null;\n            try {\n                restVariable = objectMapper.readValue(request.getInputStream(), RestVariable.class);\n            } catch (Exception e) {\n                throw new FlowableIllegalArgumentException(\"Error converting request body to RestVariable instance\", e);\n            }\n\n            if (restVariable == null) {\n                throw new FlowableException(\"Invalid body was supplied\");\n            }\n            if (!restVariable.getName().equals(variableName)) {\n                throw new FlowableIllegalArgumentException(\"Variable name in the body should be equal to the name used in the requested URL.\");\n            }\n\n            result = setSimpleVariable(restVariable, planItem.getId(), false, false, RestVariable.RestVariableScope.LOCAL, CmmnRestResponseFactory.VARIABLE_PLAN_ITEM, createVariableInterceptor(planItem));\n        }\n        return result;\n    }\n    \n    @ApiOperation(value = \"Update a variable on a plan item asynchronously\", tags = { \"Plan Item Instances\" }, nickname = \"updatePlanItemVariableAsync\",\n            notes = \"This endpoint can be used in 2 ways: By passing a JSON Body (RestVariable) or by passing a multipart/form-data Object.\\n\"\n                    + \"NB: Swagger V2 specification does not support this use case that is why this endpoint might be buggy/incomplete if used with other tools.\")\n    @ApiImplicitParams({","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/PlanItemInstanceVariableResource.java#L80-L116","documentation":"Thrown in updateVariable when the JSON body cannot be deserialized into a RestVariable object: Jackson throws during objectMapper.readValue(request.getInputStream(), RestVariable.class), and the resource wraps the exception in FlowableIllegalArgumentException. It means the request body is malformed or does not conform to the RestVariable schema.","triggerScenarios":"PUT /cmmn-runtime/plan-item-instances/{id}/variables/{name} with a non-JSON body, invalid JSON syntax, missing Content-Type, or JSON that violates RestVariable structure (e.g. name/value fields of wrong type).","commonSituations":"Sending form-encoded or XML instead of JSON; trailing commas or unquoted keys; value objects Jackson cannot map; character-encoding issues corrupting the stream; proxy stripping the body.","solutions":["Validate the body is well-formed JSON with the RestVariable shape: {\"name\":\"...\",\"type\":\"...\",\"value\":...}.","Set Content-Type: application/json on the request.","Confirm the value type matches one supported by RestVariableTypeConverter (string, integer, boolean, date ISO format, etc.).","Inspect the cause chain of the FlowableIllegalArgumentException for the exact Jackson deserialization message."],"exampleFix":"// before\nclient.put(url, \"value=42\"); // form-encoded, not JSON\n// after\nclient.putJson(url, \"{\\\"name\\\":\\\"amount\\\",\\\"type\\\":\\\"integer\\\",\\\"value\\\":42}\");","handlingStrategy":"validation","validationCode":"// validate before sending\nconst body = { name: variableName, type: 'integer', value: 42 };\nJSON.parse(JSON.stringify(body)); // throws on circular/invalid payloads\nif (!body.name) throw new Error('RestVariable requires name');","typeGuard":"function isRestVariable(v) { return v !== null && typeof v === 'object' && typeof v.name === 'string' && 'value' in v; }","tryCatchPattern":"try { api.updateVariable(id, name, body); }\ncatch (FlowableIllegalArgumentException e) { logBodyForDebug(body); throw new Error('Malformed RestVariable body: ' + e.getCause(), e); }","preventionTips":["Always send Content-Type: application/json.","Validate payloads against the RestVariable schema before posting.","Use ISO-8601 strings for date variable values.","Check the cause chain for the exact Jackson parse error."],"tags":["rest-api","json","deserialization","cmmn"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}