Search code examples
pythongoogle-tasks-apigoogle-tasks

Return All Tasks dosen't return completed tasks


I develop a little command-line app to bring google tasks, but return all tasks in a specified task list does not return completed tasks, wish showCompleted is true by default

So I tried many times in Live API and only uncompleted tasks are returned, see by your self: https://developers.google.com/tasks/v1/reference/tasks/list

For those who did not understand go to you Gmail and add a non concluded task and a concluded one, then go to the live API and test it, you will see the concluded task doesn't appear even if you set showCompleted to True! How in the online version of Google Tasks can they get the tasks completed?

tasks = service.tasks().list(tasklist='@default').execute()

for task in tasks['items']:
  print task['title']
  print task['status']
  print task['completed']

Solution

    • You want to retrieve the task list of with and without "completed" using Python.
    • You have already been able to use Tasks API.

    If my understanding is correct, how about this modification?

    In order to retrieve the completed tasks, please use the property of showHidden as follows. The property of showCompleted is True as default.2

    Modified script:

    From:
    tasks = service.tasks().list(tasklist='@default').execute()
    
    for task in tasks['items']:
      print task['title']
      print task['status']
      print task['completed']
    
    To:
    tasks = service.tasks().list(tasklist='@default', showHidden=True).execute()  # Modified
    for task in tasks['items']:
        print(task['title'])
        print(task['status'])
        if 'completed' in task:  # Added
            print(task['completed'])
        else:
            print('not completed')
    

    Reference:

    If I misunderstood your question and this was not the result you want, I apologize.