{"record":{"id":"d4a178a5636ecd99","repo":"flowable/flowable-engine","slug":"variable-name-in-the-body-should-be-equal-to-the-n-d4a178","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":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableResource.java","lineNumber":107,"sourceCode":"            @ApiResponse(code = 200, message = \"Indicates the variables was updated and the result is returned.\"),\n            @ApiResponse(code = 400, message = \"Indicates the name of a variable to update was missing or that an attempt is done to update a variable on a standalone task (without a process associated) with scope global. Status message provides additional information.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested task was not found or the task does not have a variable with the given name in the given scope. Status message contains additional information about the error.\"),\n            @ApiResponse(code = 415, message = \"Indicates the serializable data contains an object for which no class is present in the JVM running the Flowable engine and therefore cannot be deserialized.\"),\n    })\n    @PutMapping(value = \"/runtime/tasks/{taskId}/variables/{variableName}\", produces = \"application/json\", consumes = {\"application/json\", \"multipart/form-data\"})\n    public RestVariable updateVariable(@ApiParam(name = \"taskId\") @PathVariable(\"taskId\") String taskId,\n            @ApiParam(name = \"variableName\") @PathVariable(\"variableName\") String variableName,\n            @ApiParam(hidden = true) @RequestParam(value = \"scope\", required = false) String scope,\n            HttpServletRequest request) {\n\n        Task task = getTaskFromRequestWithoutAccessCheck(taskId);\n\n        RestVariable result = null;\n        if (request instanceof MultipartHttpServletRequest) {\n            result = setBinaryVariable((MultipartHttpServletRequest) request, task, 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            }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableResource.java#L89-L125","documentation":"When updating a task variable via multipart (PUT /runtime/tasks/{taskId}/variables/{variableName}), Flowable reads the file's original filename/content as the variable name and compares it with the variableName in the URL. FlowableIllegalArgumentException is thrown if they differ. The REST API requires the body-embedded name to exactly match the URL path variable so there is no ambiguity about which variable is being written.","triggerScenarios":"PUT with multipart/form-data to /runtime/tasks/{taskId}/variables/{variableName} where the file part's name/filename (used as variable name) does not equal the {variableName} path segment.","commonSituations":"Uploading a file named 'report.pdf' while URL says variables/doc; renaming files but keeping hardcoded URL; tooling that sets the multipart part name to the field name instead of the variable name.","solutions":["Make the multipart file part's name/filename exactly match the {variableName} in the URL.","Alternatively change the URL path to match the filename embedded in the request.","Strip path components/extensions client-side if the full filename is being sent but only the base name is expected."],"exampleFix":"// before\ncurl -X PUT '.../tasks/123/variables/doc' -F 'file=@report.pdf'\n\n// after\ncurl -X PUT '.../tasks/123/variables/report' -F 'file=@report.pdf'","handlingStrategy":"validation","validationCode":"function validateMultipartVariableUpdate(urlVariableName, file) {\n  const bodyName = file.name.replace(/\\.[^.]+$/, ''); // adjust to API's extraction rule\n  if (bodyName !== urlVariableName) {\n    throw new Error(`multipart variable name '${bodyName}' must equal URL name '${urlVariableName}'`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await putMultipart(url, formData);\n} catch (e) {\n  if (String(e.message).includes('should be equal to the name used in the requested URL')) {\n    // retry with name derived from the file part\n  }\n  throw e;\n}","preventionTips":["Derive the URL variable name from the uploaded file's name programmatically, not hardcoded.","Add a client-side assertion that filename and URL variable match before sending.","Rename files to the desired variable name before upload instead of divergent names."],"tags":["rest-api","flowable","validation","multipart"],"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"}