Comments (9)
It worked, cheers for you fast and effective responses mate!
from python-o365.
Can you include your stack trace?
from python-o365.
hi, i just realised that i was not using a schedule to retrieve a calendar, can you help on what I am missing?
schedule = Schedule(authentication)
result = schedule.calendars
print(result)
CALENDAR
ev = Event(authentication)
ev.setSubject('coffee')
ev.setStart(time.gmtime(time.time() + 3600)) # start an hour from now.
ev.setEnd(time.gmtime(time.time() + 7200)) # end two hours from now.
new_e = ev.create()
I am trying to understand how to get a calendar from a scheduler and pass it to event.create
from python-o365.
Well, the library does a lazy load, so you need to get the calendars like this:
result = schedule.getCalendars()
Then you create the event with the calendar of your choosing, assuming you only have one, it should look something like this:
result = schedule.getCalendars()
ev = Event(auth=authentication,cal=result[0])
It's a bit of a wonky system I'll admit. It's largely because I'm just exposing the API in Python fairly directly. I'm starting to realize I need to rewrite this to work in a more sensible way.
from python-o365.
hey again and thank you but this line:
result = schedule.getCalendars() is a boolean
from python-o365.
oh, hehe, sorry. It's been a while clearly. This should work:
schedule = Schedule(authentication)
schedule.getCalendars()
result = schedule.calendars
from python-o365.
Still same issue, ill show you all my code to understand what I am trying to do. So I am trying to see if your library is suitable for posting and getting events for my web application, what I am having now is this:
authentication = (e, p) // e is my mail and p is my password
bookings = []
json_outs = {}
schedule = Schedule(authentication)
try:
result = schedule.getCalendars()
print('\nFetched calendars for', e, 'was successful:', result, '\n')
except:
print('Login failed for', e, '\n')
for cal in schedule.calendars:
print('Attempting to fetch events for', e, '\n')
try:
result = cal.getEvents()
print('Got:', len(cal.events), 'events in total from given calendar')
except:
print('failed to fetch events')
print('\nAttempting for event information, events I got: \n')
for event in cal.events:
bookings.append(event.fullcalendarioJson())
json_outs[e] = bookings
print(bookings[0])
print(bookings[1])
print(bookings[2])
schedule = Schedule(authentication)
schedule.getCalendars()
result = schedule.calendars
ev = Event(authentication, result[0])
ev.setSubject('coffee')
ev.setStart(time.gmtime(time.time() + 3600)) # start an hour from now.
ev.setEnd(time.gmtime(time.time() + 7200)) # end two hours from now.
new_e = ev.create()
It fetches the events and I indeed have them in a dictionary but when i go to "ev." lines I have the following error with the program output being this:
Traceback (most recent call last):
File "/Users/jk/Documents/ExchangeTesting/narcolapser.py", line 46, in
ev.setSubject('coffee')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/O365/event.py", line 223, in setSubject
self.json['Subject'] = val
TypeError: 'tuple' object does not support item assignment
Process finished with exit code 1
from python-o365.
your problem is in instantiation of Event. Because the constructor for Event uses key word arguments, authentication and your calendar aren't going to the right places. The method declaration looks like this:
def __init__(self,json=None,auth=None,cal=None,verify=True):
If you don't assign the key word arguments, it just does them in order. Which means you are passing in your authentication tuple as the json, and your calendar as authentication. Try updating your event line to this:
ev = Event(auth=authentication, cal=result[0])
from python-o365.
No problem. Glad to help!
from python-o365.
Related Issues (20)
- Cookie based auth HOT 1
- What does the msgraph-sdk-python mean for the future of this project? HOT 3
- Client Error: 404 Client Error: Not Found for url: when switching between sharepoint and onedrive resources HOT 5
- I can't use refresh token in airflow environment HOT 3
- ZoneInfo object has no attribute Zone exception HOT 3
- Reach to the file name by the path HOT 1
- 'zoneinfo.ZoneInfo' object has no attribute 'zone' HOT 1
- "Protocol not provided to Api Component" when copying files from a shared OneDrive HOT 3
- requirements.txt not consisting with setup.py dependency versions HOT 1
- TimeZone Handling HOT 1
- No email rule creation
- 2.0.33 : 'MSGraphProtocol' object has no attribute 'keyword_data_store' HOT 16
- O365.utils.utils.Query.any does not support negate() and does not follow the group? HOT 4
- No auth token found. Authentication Flow needed HOT 1
- Inconsistent behavior of `attachment.attachment_type` in legacy vs new Outlook HOT 4
- a small issue in "python-o365-master\O365\connection.py" HOT 1
- How to ignore email signature files HOT 2
- 'bucket_id' is missing in accepted update parameters HOT 1
- Logic error regarding the use of duple types (Query and str)
- How to determine mailbox access? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-o365.