Fix task creation payload to match Vikunja API requirements

- Add required fields to payload: description, done, priority, project_id
- Initialize labels as empty array in payload
- Set due_date to null when not provided (instead of omitting)
- Matches Vikunja API structure based on user-provided endpoint details

Co-authored-by: Mord0reK <135718526+Mord0reK@users.noreply.github.com>
pull/878/head
copilot-swe-agent[bot] 2025-11-17 13:00:28 +07:00
parent 9200a72e1c
commit ef3e7f73f3
1 changed files with 11 additions and 1 deletions

@ -394,12 +394,22 @@ func (widget *vikunjaWidget) createTask(title string, dueDate string, labelIDs [
// Use the configured project ID for creating tasks
url := fmt.Sprintf("%s/api/v1/projects/%d/tasks", widget.URL, widget.ProjectID)
// Build payload matching Vikunja API structure
// Based on Vikunja API documentation and user-provided payload structure
payload := map[string]interface{}{
"title": title,
"title": title,
"description": "",
"done": false,
"priority": 0,
"labels": []interface{}{}, // Empty array, labels will be added separately
"project_id": widget.ProjectID,
}
// Add due_date if provided
if dueDate != "" {
payload["due_date"] = dueDate
} else {
payload["due_date"] = nil
}
jsonData, err := json.Marshal(payload)