ToDoist API Python SDK throwing 410 Error

278 views Asked by At

Background: I'm trying to write a Python script that creates a task in ToDoist using their REST API Python SDK, based on the charge percentage of my dog's Fi Collar (obtained via Pytryfi). Basically, if the Fi collar's battery falls below a certain threshold, create a new task.

Problem: A 401 error is returned when trying to use the todoist_api_python SDK, copied exactly from Todoist's website.

Following these instructions, I was able to install todoist-api-python, but when I run this code (using a real API key):

pip install todoist-api-python

from todoist_api_python.api import TodoistAPI

api = TodoistAPI("XXXXXXX")

try:
    projects = api.get_projects()
    print(projects)
except Exception as error:
    print(error)

I receive this error:

410 Client Error: Gone for url: https://api.todoist.com/rest/v1/projects

I do know there has been a recent change from v1->v2 of this API, and indeed when I put the URL above from the error message in to a browser with ../v2/projects, I see a list of my tasks.

I don't know how to make the todoist-api-python SDK point to the new URL. I'd really appreciate any help you can offer! Thanks!

1

There are 1 answers

0
PotHix On

Be sure you're using the version 2 of todoist-api-python, as this is the one that uses the latest version of the API: https://pypi.org/project/todoist-api-python/

You're probably using an old version that relies on REST API v1.