{"record":{"id":"4df63bba69212602","repo":"flowable/flowable-engine","slug":"invalid-body-was-supplied-4df63b","errorCode":null,"errorMessage":"Invalid body was supplied","messagePattern":"Invalid body was supplied","errorType":"exception","errorClass":"FlowableException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ProcessInstanceVariableResource.java","lineNumber":117,"sourceCode":"\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.\")\n    @ApiImplicitParams({\n            @ApiImplicitParam(name = \"body\", type = \"org.flowable.rest.service.api.engine.variable.RestVariable\", value = \"Create a variable on a process instance\", paramType = \"body\", example = \"{\\n\" +\n                    \"    \\\"name\\\":\\\"intProcVar\\\"\\n\" +\n                    \"    \\\"type\\\":\\\"integer\\\"\\n\" +","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/ProcessInstanceVariableResource.java#L99-L135","documentation":"Flowable's REST endpoint for updating a process-instance variable requires a JSON body deserializable into a RestVariable object. After parsing, if the deserialized object is null (i.e. an empty body or a JSON literal 'null'), the endpoint throws FlowableException(\"Invalid body was supplied\"). This guards downstream logic that expects a non-null variable payload.","triggerScenarios":"PUT/POST to /runtime/process-instances/{processInstanceId}/variables/{variableName} with an empty request body, a body of literal 'null', or a body whose content is dropped before it reaches objectMapper.readValue(request.getInputStream(), RestVariable.class).","commonSituations":"Clients sending PUT without a body (e.g. curl -X PUT without -d), proxies/gateways stripping bodies, Content-Type header set but payload omitted, or test scripts calling the endpoint with no data.","solutions":["Send a valid JSON RestVariable body, e.g. {\"name\":\"<variableName>\",\"type\":\"string\",\"value\":\"myValue\"}.","Ensure the variable name in the body matches the {variableName} URL segment.","Verify the client sets Content-Type: application/json and actually transmits the body (check curl -v output or proxy logs).","If using a reverse proxy, confirm it does not drop request bodies on PUT."],"exampleFix":"// before\ncurl -X PUT -H 'Content-Type: application/json' \\\n  http://host/flowable-rest/runtime/process-instances/123/variables/orderId\n\n// after\ncurl -X PUT -H 'Content-Type: application/json' \\\n  -d '{\"name\":\"orderId\",\"type\":\"string\",\"value\":\"ABC-1\"}' \\\n  http://host/flowable-rest/runtime/process-instances/123/variables/orderId","handlingStrategy":"validation","validationCode":"const body = { name: variableName, type: 'string', value: 'x' };\nif (!body || !body.name) throw new Error('RestVariable body required');\nawait fetch(url, { method: 'PUT', headers: {'Content-Type':'application/json'}, body: JSON.stringify(body) });","typeGuard":"function isValidRestVariable(v) {\n  return v != null && typeof v.name === 'string' && v.name.length > 0 && 'value' in v;\n}","tryCatchPattern":"try {\n  const res = await api.put(`/process-instances/${id}/variables/${name}`, body);\n} catch (e) {\n  if (e.response && /Invalid body was supplied/.test(e.response.data && e.response.data.message || '')) {\n    // rebuild and retry with a proper RestVariable body\n  }\n}","preventionTips":["Never send a PUT without a JSON body to variable endpoints.","Build the body from the same variable name used in the URL.","Log request bodies in integration tests to catch empty payloads early."],"tags":["rest-api","missing-request-body","flowable"],"backgroundTag":"empty-required-field","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"}