-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP 400 accessing calendar for room mailbox #364
Comments
I actually passed in the accounts email address into the schedule() constructor and it now seems to pass but once it hits the query builder stage I get this:
I was expecting a schedule type object to be returned?? |
Instead of:
Do:
|
@janscas - Im not sure that's the problem. It's complaining that the line: |
the calendar seems to be incorrect then as it's now found.. try: for calendar in schedule.list_calendars():
print(calendar.name)
if calendar.name == 'IT Vacation Calendar':
print('found!') You should see 'found!'. If not, check all the printed calendar names to see the correct name. |
so if i pass in a resource into the schedule() constructor I get something like this... |
Can you paste the complete code block of both cases? |
` CLIENT_ID = os.environ['CLIENT_ID_CAL']
And ` CLIENT_ID = os.environ['CLIENT_ID_CAL']
|
weird but if i set main_resource in the Account object to the resource email address and set the get_calendar() method to search for 'Calendar', everything seems to work. I somehow can't leave the main_resource attribute or the resource attribute from the schedule() constructor empty and just run the list_calendars() function to show all calendars. I think specifically hardcoding the resource email address is fine for what I need though. Thanks for all the help |
so i got it working for the most part but I'm noticing some incorrect data being retrieved. My query is set to only retrieve events between 11/25/2019 and 11/29/2019. It does this successfully but it's showing the wrong start and end dates for some events. Some events are showing up as having a start date of 11/24/2019 4PM to 11/27/2019 4PM but the real event on the calendar is actually from 11/25/2019 12AM to 11/28/2019 12AM. In addition, some events are showing the following log message: Code block for reference: `
|
Well I feel really dumb - the main issue above is because it's returning the date values in UTC timezone. I need to convert them to PST. Will look into this on my own since the attempts I've tried have been unsuccessful. The issue with the "couldn't parse event response" still remains. Any ideas what could be causing that? |
The library tries to guess the local timezone and it defaults to UTC if not found. You can pass a “timezone” to the protocol instantiation to automatically convert all timezones. For example:
|
Also read this about the include recurring option: https://github.com/O365/python-o365/blob/master/README.md#notes-regarding-calendars-and-events |
I must be doing something wrong because i changed mine to and then changed the recurring option to False and now I'm getting this:
|
No, it’s my fault... Use: from pytz import timezone
protocol = MSGraphProtocol(timezone=timezone('America/Los_Angeles')) I’ll commit a change to allow to pass strings to the timezone param. |
something weird must be going on... using the code above i no longer get the AttributeError but it seems like the timezone is only correct for one of the entries. Everything else is still returning the same (ie, start time for 4PM when it should really read 12AM). Also - not sure if you caught my other thing from an earlier post but I am getting intermittent results that just output the following message:
|
Ok, I’ll investigate that... About this:
It’s just a debug message. When the event has no response (it’s not accepted or whatever) the response time could not be parsed. |
I've run some test changing to/from different timezones on a test calendar and It completely works for me: account = Account(credentials, timezone='Europe/London')
calendar = account.schedule().get_default_calendar()
q = calendar.q('start').equals(dt.datetime(2019, 8, 10)).on_attribute('end').equals(dt.datetime(2019, 8, 30))
for event in calendar.get_events(limit=4, query=q):
print(event.start, event.end) This returns (Note the +1 which is the London offset in August as DST apply):
Now, the same query changing the applied timezone to 'Europe/Paris': account = Account(credentials, timezone='Europe/Paris')
calendar = account.schedule().get_default_calendar()
q = calendar.q('start').equals(dt.datetime(2019, 8, 10)).on_attribute('end').equals(dt.datetime(2019, 8, 30))
for event in calendar.get_events(limit=4, query=q):
print(event.start, event.end) This returns (Note the +2 which is the Paris offset in August as DST apply):
|
I think i was misunderstanding the timezone piece and asking the wrong question. I believe mine is working correctly as well. An example below shows: The actual event in my Outlook is for 11/27 12AM PST to 11/29 12AM PST. The -8:00 offset would mean the 11/26 16:00:00 above would actually translate to 11/27 12AM PST. I guess the "right" question to ask here is how can I convert the output to PST so if i gave this report to someone they could easily identify the start and end time without mentally figuring out 11-26 16:00:00-08:00 is actually 11/27 12AM local time. I guess i could live with the above situation if there was no way around it but the odd thing is i have 2 other events on the calendar that dont have a start and stop time of 12AM and they are reporting the correct PST time. See correct examples below:
Both these timestamps match the time for the event on the calendar. Any event that start/end at 12AM is showing the timestamp with the -8hr offset. |
event.start and event.end will always be a datetime with a timezone. So you can always get the datetime timezone or convert it to another timezone |
i used something like.... |
If you define for example your local timezone to be "Europe/London": account = Account(credentials, timezone="Europe/London") then all datetimes will be set to this timezone. from pytz import timezone
schedule = account.schedule()
message = list(schedule.get_messages())[0]
tz_target = timezone('Europe/Paris')
print(message.start)
print(message.start.astimezone(tz_target)) This will print:
|
lol sorry im just dumb....i just realized everything works . The events that were showing up as 16:00 PST is actually the right time in PST time. The event was using Dublin timezone which is 12AM. |
Actually...i did more checks and even some events that are set to PST and have a start time of 12AM are showing up as 16:00-08:00 when I run my script. I'm not sure why only the stuff that's set to start and end at 12AM are affected. All others appear fine. It made sense for events set with Dublin timezone to show up as 16:00 PST when the event is set to 12AM but if the event timezone is set to Pacific and still shows up as 16:00 PST that to me is clearly wrong? |
You may need to provide sample data here. Basically the process is always this:
Maybe the timezone conversion table (point 3) is somehow failing in your case. Then with this we can compare the correct logical conversion with the library output. |
Using the sample in the documentation, I created this test but am getting a "Bad Request" error message saying
Am I doing something wrong? I've added Calendars.Read application access and Calendar.Read.Shared delegated permissions. Not sure if this is supported but I assume it has something to do with the permissions.
The text was updated successfully, but these errors were encountered: