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

new_event.save(): TypeError: argument of type 'NoneType' is not iterable

Open loglux opened this issue 4 years ago • 6 comments

O365 2.015 (updated today) It simply doesn't work

        account = Account(credentials)
        schedule = account.schedule()
        print(schedule)
        calendar = schedule.get_default_calendar()
        bin_collection = calendar.new_event()  # creates a new unsaved event
        bin_collection.subject = 'Bin collection'
        bin_collection.location = 'Belfast'
        #new_event.start = dt.datetime(2021,6,12, 0, 0, 0)
        bin_collection.start = dt.datetime(2021, 6, 30, 0, 0)
        bin_collection.is_all_day = True
        print(bin_collection)
        bin_collection.save()

Output

Schedule resource: me
Subject: Bin collection (starts: 2021-06-30 00:00:00 and ends: 2021-07-01 00:00:00)
Traceback (most recent call last):
  File "C:\Users\call2\PycharmProjects\webwatch\cal.py", line 47, in <module>
    cal.check_calendar()
  File "C:\Users\call2\PycharmProjects\webwatch\cal.py", line 28, in check_calendar
    bin_collection.save()
  File "C:\Users\call2\PycharmProjects\webwatch\venv\lib\site-packages\O365\calendar.py", line 1432, in save
    data = self.to_api_data()
  File "C:\Users\call2\PycharmProjects\webwatch\venv\lib\site-packages\O365\calendar.py", line 967, in to_api_data
    if 'attachments' in restrict_keys:
TypeError: argument of type 'NoneType' is not iterable

loglux avatar Jun 11 '21 16:06 loglux

How this issue can be resolved? Everything looks correct. It's not clear which argument is NoneType here

loglux avatar Jun 18 '21 09:06 loglux

This was solved in a later commit. You should try the last version. If it doesn't work report back please

alejcas avatar Sep 03 '21 09:09 alejcas

A spoon in time could save nine. I don't have a chance to check it now. The program, which required this option is no longer needed. But I'll keep it in mind and try when I have time. The option can be used in future anyway.

loglux avatar Sep 05 '21 15:09 loglux

version 2.0.16 and the result is exactly the same we can't see a result from print(bin_collection) Subject: Bin collection (starts: 2021-09-30 00:00:00 and ends: 2021-10-01 00:00:00) But seems nothing has been done to fix the issue as the even reference point to the same line

line 967, in to_api_data if 'attachments' in restrict_keys: TypeError: argument of type 'NoneType' is not iterable

loglux avatar Sep 22 '21 19:09 loglux

If it doesn't work report back please

it doesn't

loglux avatar Sep 22 '21 19:09 loglux

commented lines in calendar.py to force it to work

      #  if 'attachments' in restrict_keys:
       #     self.attachments._update_attachments_to_cloud()

P.S. Probably there is a mistake in

    def to_api_data(self, restrict_keys=None):
        ....
        if 'attachments' in restrict_keys:
        self.attachments._update_attachments_to_cloud()

So, why we get this message

line 967, in to_api_data  
if 'attachments' in restrict_keys:
TypeError: argument of type 'NoneType' is not iterable

loglux avatar Sep 23 '21 19:09 loglux