我正在使用Microsoft的示例Django應用程序並試圖從現在開始讀取日曆事件回到1年前。該API請求使用Python請求函數完成:如何爲Outlook日曆API調用插入開始日期和結束日期和時間
response = requests.get(url, headers = headers, params = parameters)
頁眉標準的API請求相關:
headers = { 'User-Agent' : 'python_events/1.0',
'Authorization' : 'Bearer {0}'.format(token),
'Accept' : 'application/json',
'X-AnchorMailbox' : user_email }
而且,對於參數我傳遞:
query_parameters = {'$top': '2500',
'$select': 'Id,Subject,Start,End',
'$orderby': 'Start/DateTime ASC'}
現在,我試圖將開始和結束日期定義爲:
now = datetime.utcnow()
one_year = now - timedelta(days=365)
now = now.isoformat()
one_year = one_year.isoformat()
然後,試圖在同一query_parameters字典插入的startDateTime和endDateTime參數:
query_parameters = {'$top': '2500',
'$select': 'Id,Subject,Start,End',
'$orderby': 'Start/DateTime ASC',
'startDateTime' : one_year,
'endDateTime': now
}
我仍然得到事件之前,從一年前的轉儲。我在這裏做錯了什麼? query_parameters是插入開始和結束日期和時間的正確位置嗎?
'url'的價值是什麼? –
嗨賈森,網址值是:https://outlook.office.com/api/v2.0/Me/Events –