Reputation: 476
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.
Upvotes: 0
Views: 46
Reputation: 56
Based on the UpdateTask documentation, you would need to use the duration
and duration_unit
fields instead of a duration object.
api.update_task(task_id="foobar", duration=30, duration_unit='minute')
Upvotes: 0