{"record":{"id":"ea5575c034b12e05","repo":"flowable/flowable-engine","slug":"error-converting-request-body-to-restvariable-inst-ea5575","errorCode":null,"errorMessage":"Error converting request body to RestVariable instance","messagePattern":"Error converting request body to RestVariable instance","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ExecutionVariableResource.java","lineNumber":117,"sourceCode":"\n        Execution execution = getExecutionFromRequestWithoutAccessCheck(executionId);\n\n        RestVariable result = null;\n        if (request instanceof MultipartHttpServletRequest) {\n            result = setBinaryVariable((MultipartHttpServletRequest) request, execution, false, false);\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\n            RestVariable restVariable = null;\n\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, execution, false, false);\n        }\n        return result;\n    }\n    \n    @ApiOperation(value = \"Update a variable on an execution asynchronously\", tags = { \"Executions\" }, nickname = \"updateExecutionVariableAsync\",\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":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ExecutionVariableResource.java#L99-L135","documentation":"FlowableIllegalArgumentException thrown by updateVariable when the JSON request body cannot be deserialized by Jackson into a RestVariable instance. The raw body is malformed JSON or does not conform to the RestVariable shape.","triggerScenarios":"PUT /runtime/executions/{id}/variables/{variableName} with a non-multipart body that is invalid JSON, wrong content type, or fields of the wrong type (e.g. 'value' as an object where a primitive/array is expected, or 'type' not resolvable).","commonSituations":"Sending form-encoded or plain text instead of JSON, unquoted or trailing-comma JSON, custom Java objects serialized inline that Jackson cannot map to RestVariable, charset/BOM issues in the body.","solutions":["Send a valid JSON body matching RestVariable: {\"name\":\"...\",\"type\":\"string\",\"value\":...} with Content-Type: application/json","Validate the JSON with a parser/linter before sending","Check that the 'type' field is a supported Flowable variable type name","Inspect the wrapped exception cause (e) in server logs for the exact Jackson deserialization error"],"exampleFix":"// before\nname=status&value=active  (form-encoded)\n// after\n{\"name\":\"status\",\"type\":\"string\",\"value\":\"active\"} with Content-Type: application/json","handlingStrategy":"validation","validationCode":"const body = { name: variableName, type: inferFlowableType(value), value };\nJSON.parse(JSON.stringify(body)); // throws if unserializable to valid JSON\nheaders[\"Content-Type\"] = \"application/json\";","typeGuard":"function isRestVariable(b) { return typeof b === \"object\" && b !== null && typeof b.name === \"string\" && (b.value === undefined ? false : \"value\" in b); }","tryCatchPattern":"try { return await updateVariable(id, name, body); }\ncatch (e) { if (e.status === 400 && /converting request body/i.test(e.message)) throw new Error(\"Invalid RestVariable JSON: \" + e.message); throw e; }","preventionTips":["Always send Content-Type: application/json","Match the RestVariable schema: name, type, value","Pre-validate JSON bodies with JSON.parse or a schema validator","Use supported Flowable variable type names in the 'type' field"],"tags":["rest","json","deserialization","variables"],"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"}