0
即时得到错误的Python/JSON - KeyError异常“身体”创建
>>> appt = CreateEvent(authentication, result[0].calendarId, subject_text, start_time, end_time, subscribers, content)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 9, in CreateEvent
KeyError: 'Body'
的下方,代码时,即时通讯新的JSON所以不明白为什么这个心不是工作。所有其他工作,但我看到身体上的错误,是因为即时通讯使用两个[]? 这是要发送到Office 365 API,所以它期望它的格式。
感谢
def CreateEvent(auth, calendar, subject, start_time, end_time, attendees, content):
create_url = 'https://outlook.office365.com/api/v1.0/me/calendars/{0}/events'.format(calendar)
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
data = {}
data['Subject'] = subject
data['Start'] = start_time
data['End'] = end_time
data['Attendees'] = attendees
data['Body']['Content'] = content
data['Body']['ContentType'] = 'Text'
content_data = json.dumps(data)
好像'data'没有键'Body' –