{"record":{"id":"2c1d221b28cccebe","repo":"flowable/flowable-engine","slug":"request-body-could-not-be-transformed-to-a-restvar-2c1d22","errorCode":null,"errorMessage":"request body could not be transformed to a RestVariable instance.","messagePattern":"request body could not be transformed to a RestVariable instance\\.","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ProcessInstanceVariableResource.java","lineNumber":113,"sourceCode":"    public RestVariable updateVariable(@ApiParam(name = \"processInstanceId\") @PathVariable(\"processInstanceId\") String processInstanceId, @ApiParam(name = \"variableName\") @PathVariable(\"variableName\") String variableName,\n            HttpServletRequest request) {\n\n        Execution execution = getExecutionFromRequestWithoutAccessCheck(processInstanceId);\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            RestVariable restVariable = null;\n            try {\n                restVariable = objectMapper.readValue(request.getInputStream(), RestVariable.class);\n            } catch (Exception e) {\n                throw new FlowableIllegalArgumentException(\"request body could not be transformed to a 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 single variable on a process instance asynchronously\", tags = { \"Process Instance Variables\" }, nickname = \"updateProcessInstanceVariableAsync\",\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                    + \"Note that scope is ignored, only local variables can be set in a process instance.\\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.\")","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ProcessInstanceVariableResource.java#L95-L131","documentation":"Flowable REST throws FlowableIllegalArgumentException when the request body of a variable update cannot be deserialized by Jackson into a RestVariable instance. The body is not valid JSON for the variable schema (wrong Content-Type, malformed JSON, or unsupported structure).","triggerScenarios":"PUT /runtime/process-instances/{id}/variables/{name} with a non-JSON body, syntactically invalid JSON, or a body sent without application/json content type so readValue fails.","commonSituations":"Client sends form-encoded/plain text instead of JSON; truncation of the body by a proxy; sending a bare value (e.g. just 42) instead of a RestVariable object with name/type/value.","solutions":["Send a complete RestVariable JSON object: {\"name\":\"...\",\"type\":\"...\",\"value\":...} with Content-Type: application/json.","Validate the JSON body with a linter/client before sending.","Check that no proxy/gateway truncates or transforms the request body."],"exampleFix":"// before\nPUT .../variables/count  body: 42\n// after\nPUT .../variables/count  body: {\"name\":\"count\",\"type\":\"integer\",\"value\":42}","handlingStrategy":"validation","validationCode":"JSON.parse(JSON.stringify({name: varName, type: varType, value: varValue})); // ensure serializable valid body","typeGuard":"const isRestVariable = (b) => b != null && typeof b === 'object' && typeof b.name === 'string' && 'value' in b;","tryCatchPattern":"try { put(url, body, {headers:{'Content-Type':'application/json'}}); } catch (e) { if (/RestVariable/.test(e.response?.data?.message || '')) { /* fix body shape */ } throw e; }","preventionTips":["Always send Content-Type: application/json","Send the full RestVariable object, not a bare value","Validate JSON bodies before sending"],"tags":["rest-api","json","deserialization"],"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"}