[Python] How to change a Todoist task's duration with the update_task Python and REST API?

Discussão em 'Python' iniciado por Stack, Fevereiro 2, 2025.

  1. Stack

    Stack Membro Participativo

    I've tried Todoist APIs' update_task and I get error code 400:


    "Client Error: bad request for url https://api.todoist.com/rest/v2/tasks/[...]" with
    ​

    # Define the task ID and the new duration
    task_id = "0123456789"
    new_duration = {
    "amount": 30,
    "unit": "minute"
    }

    # Update the task's duration
    api.update_task(task_id=task_id, duration=new_duration)


    and

    payload = {
    "duration": {
    "amount": 30,
    "unit": "minute"
    }
    }
    response = requests.post(f"{TODOIST_API_URL}/{task_id}", headers=headers, json=payload)


    What is the correct way of using the duration args? Or is the problem somewhere else?

    The "content" of the task does update successfully. The task is set in the future and I also tried setting duration as null and valid from the Todoist app before calling the API but I get the same error.

    Continue reading...

Compartilhe esta Página