python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

Unable to delete Todo Task Folder

Open Nitschi opened this issue 4 years ago • 1 comments

Hello :)

I'm trying to automate the creation, deletion, etc. of MS Todo Tasks with python-o365. Unfortunately I run into an error if I try to delete a folder. The error only occurs if the Folder actually exists.

Code:

        token_backend = FileSystemTokenBackend(token_path=Config.MS_TODO_TOKEN_PATH, token_filename="mstodo.token")
        account = Account(Config.CREDENTIALS, protocol=MSOffice365Protocol(), token_backend=token_backend)
        if not account.is_authenticated:
            scopes = MSOffice365Protocol().get_scopes_for('tasks_all')
            account.authenticate(scopes=scopes)
        api = account.tasks()

        folder = next(folder for folder in api.list_folders() if folder.name == "test_folder_name")
        folder.delete()

The Error:

File "/opt/code/anaconda3/envs/nukleus-gate3/lib/python3.9/site-packages/O365/connection.py", line 762, in _internal_request
    raise HTTPError('{} | Error Message: {}'.format(e.args[0], error_message), response=response) from None
Exception: 409 Client Error: Conflict for url: https://outlook.office.com/api/v2.0/me/taskfolders/ASDFASDFASDF= | Error Message: A folder with the specified name already exists.

Could it be that there is a missing case (namely 'delete') here: https://github.com/O365/python-o365/blob/ddd7b525f21e649c4592de0370095a5535b4058b/O365/connection.py#L683-L698

Nitschi avatar Dec 22 '21 13:12 Nitschi

It could be, by I can’t tell right now. Can you try?

alejcas avatar Jan 13 '22 21:01 alejcas