{"record":{"id":"fcffbc3d78171610","repo":"flowable/flowable-engine","slug":"a-request-body-was-expected-when-updating-the-task-fcffbc","errorCode":null,"errorMessage":"A request body was expected when updating the task.","messagePattern":"A request body was expected when updating the task\\.","errorType":"http","errorClass":"FlowableException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskResource.java","lineNumber":80,"sourceCode":"            @ApiResponse(code = 404, message = \"Indicates the requested task was not found.\")\n    })\n    @GetMapping(value = \"/runtime/tasks/{taskId}\", produces = \"application/json\")\n    public TaskResponse getTask(@ApiParam(name = \"taskId\") @PathVariable String taskId) {\n        return restResponseFactory.createTaskResponse(getTaskFromRequest(taskId));\n    }\n\n    @ApiOperation(value = \"Update a task\", tags = {\n            \"Tasks\"}, notes = \"All request values are optional. For example, you can only include the assignee attribute in the request body JSON-object, only updating the assignee of the task, leaving all other fields unaffected. When an attribute is explicitly included and is set to null, the task-value will be updated to null. Example: {\\\"dueDate\\\" : null} will clear the duedate of the task).\")\n    @ApiResponses(value = {\n            @ApiResponse(code = 200, message = \"Indicates the task was updated.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested task was not found.\"),\n            @ApiResponse(code = 409, message = \"Indicates the requested task was updated simultaneously.\")\n    })\n    @PutMapping(value = \"/runtime/tasks/{taskId}\", produces = \"application/json\")\n    public TaskResponse updateTask(@ApiParam(name = \"taskId\") @PathVariable String taskId, @RequestBody TaskRequest taskRequest) {\n\n        if (taskRequest == null) {\n            throw new FlowableException(\"A request body was expected when updating the task.\");\n        }\n\n        Task task = getTaskFromRequestWithoutAccessCheck(taskId);\n\n        // Populate the task properties based on the request\n        populateTaskFromRequest(task, taskRequest);\n\n        if (restApiInterceptor != null) {\n            restApiInterceptor.updateTask(task, taskRequest);\n        }\n\n        // Save the task and fetch again, it's possible that an\n        // assignment-listener has updated\n        // fields after it was saved so we can not use the in-memory task\n        taskService.saveTask(task);\n        task = taskService.createTaskQuery().taskId(task.getId()).singleResult();\n\n        return restResponseFactory.createTaskResponse(task);","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskResource.java#L62-L98","documentation":"Thrown by updateTask when the PUT /runtime/tasks/{taskId} request has no (or a null) JSON body. The handler requires a TaskRequest body even if all fields are optional; a missing body cannot be deserialized to a non-null TaskRequest.","triggerScenarios":"PUT /runtime/tasks/{taskId} with no body, empty body, or Content-Type not set to application/json so Spring cannot bind a TaskRequest.","commonSituations":"Client sends PUT without a JSON payload to 'touch' a task; missing Content-Type header; proxy stripping the body.","solutions":["Send a JSON body, e.g. {\"name\":\"new name\"} with Content-Type: application/json","Send {} if you only want to trigger an update without changing fields","Verify no intermediary (proxy/gateway) strips the request body"],"exampleFix":"// before\nrestTemplate.put(TASK_URL + \"/123\", null);\n// after\nrestTemplate.exchange(TASK_URL + \"/123\", HttpMethod.PUT, new HttpEntity<>(mapOf(\"name\", \"New name\"), jsonHeaders()), Void.class);","handlingStrategy":"validation","validationCode":"if (!body || typeof body !== 'object' || Object.keys(body).length === 0) body = {}; // always send at least {}","typeGuard":"function isTaskRequest(b) { return b !== null && typeof b === 'object'; }","tryCatchPattern":"catch (e) { if (e.status === 400 && /request body was expected/.test(e.body && e.body.message)) { /* resend with a JSON body */ } else throw e; }","preventionTips":["Never send a bodyless PUT; use {} as a minimal payload","Set Content-Type: application/json on every task update"],"tags":["rest","http","request-body"],"backgroundTag":"missing-required-argument","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"}