{"record":{"id":"7b1440852f07594d","repo":"flowable/flowable-engine","slug":"variable-name-in-the-body-should-be-equal-to-the-n-7b1440","errorCode":null,"errorMessage":"Variable name in the body should be equal to the name used in the requested URL.","messagePattern":"Variable name in the body should be equal to the name used in the requested URL\\.","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":90,"sourceCode":"    })\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Indicates both the plan item instance and variable were found and variable is updated.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested plan item instance was not found or the plan item instance does not have a variable with the given name. Status description contains additional information about the error.\")\n    })\n    @PutMapping(value = \"/cmmn-runtime/plan-item-instances/{planItemInstanceId}/variables/{variableName}\", produces = \"application/json\", consumes = {\n            \"application/json\", \"multipart/form-data\" })\n    public RestVariable updateVariable(@ApiParam(name = \"planItemInstanceId\") @PathVariable(\"planItemInstanceId\") String planItemInstanceId,\n            @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));","sourceCodeStart":72,"sourceCodeEnd":108,"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#L72-L108","documentation":"Thrown by PlanItemInstanceVariableResource.updateVariable when the request is a multipart upload and the variable name stored in the submitted body/entry does not match the {variableName} path segment. Flowable requires the URL and body to agree to avoid ambiguous writes. The check is FlowableIllegalArgumentException, mapped to 409/400 by the REST exception mapper.","triggerScenarios":"PUT /cmmn-runtime/plan-item-instances/{id}/variables/{variableName} with a multipart form field whose name differs from the path variable (e.g. path says 'amount', form field is 'value').","commonSituations":"Hand-built multipart clients where the form field name is hardcoded separately from the URL; templated API wrappers substituting one name in the URL and another in the body; copy-pasted request code after renaming a variable.","solutions":["Make the multipart form field name exactly match the {variableName} path segment.","Derive the URL from the same variable object used to build the body instead of hardcoding both.","Send the variable as JSON (application/json) instead of multipart if a binary file is not involved, so the body's name field controls the value."],"exampleFix":"// before\nform.field(\"value\", data); client.put(\".../variables/amount\", form);\n// after\nform.field(\"amount\", data); client.put(\".../variables/amount\", form);","handlingStrategy":"validation","validationCode":"if (formFieldName !== pathVariableName) { throw new Error(`multipart field '${formFieldName}' != URL variable '${pathVariableName}'`); }","typeGuard":null,"tryCatchPattern":"try { api.updateVariable(id, name, body); }\ncatch (FlowableIllegalArgumentException e) { if (String(e.getMessage()).includes('equal to the name used in the requested URL')) fixFieldName(); else throw e; }","preventionTips":["Generate the form field name and URL segment from the same constant.","Write a client-side unit test asserting name consistency for variable updates.","Prefer JSON bodies (single name field) over multipart unless uploading binaries."],"tags":["rest-api","request-validation","variables","cmmn"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}