MS Graph – List events (read) – Recurring events

I would like to ask you for an help related to the reading my callendar events from MS Exchange by MS Graph API.

Issue: My code do not “download” the recurring Events from calendar, all others are downloaded.

Note:

  1. Im successfully authenticated OAuth2 –> so this code is not listed here
  2. Code it self is called from another cade so variables are hand over. I use this for testing:
  • Filter_Start_Date = “2024-12-11”
  • Filter_End_Date = “2024-12-11”

My code:

# Update filters)
Filter_Start_Date = Filter_Start_Date + "T00:00:00Z"
Filter_End_Date = Filter_End_Date + "T00:00:00Z"

headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json",
    "Prefer": 'outlook.timezone="Europe/Paris"'}

params = {
    "$filter": f"start/dateTime ge '{Filter_Start_Date}' and end/dateTime le '{Filter_End_Date}'",  #! To be done --> maybe here is some issue with filtering data !!!!
    "$orderby": f"start/dateTime desc",
    "$top": 1000,
    "$count": "true",
    "$select": "subject, start, end, categories, recurrence, showAs, location, isAllDay, bodyPreview"}

Events_downloaded = {}
events_url = f"https://graph.microsoft.com/v1.0/users/{username}/events"
events_response = requests.get(url=events_url, headers=headers, params=params)

Counter = 0 
if response.status_code == 200:
    # Init page 
    Events = events_response.json()

Can anyone tell me what do I do wrong?

Thank you

Jan Vaško

Recognized by Microsoft Azure Collective

2

For sample, I created a recurring event using Microsoft Graph API:

To read the recurring events make use of below code:

access_token = "AccessToken"
username = "[email protected]"  

# Define start and end date for filtering events (adjust these dates based on your needs)
Filter_Start_Date = "2024-12-12T00:00:00Z"
Filter_End_Date = "2024-12-31T23:59:59Z"  

headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json",
    "Prefer": 'outlook.timezone="Europe/Paris"'  
}

params = {
    "startDateTime": Filter_Start_Date,
    "endDateTime": Filter_End_Date,
    "$orderby": "start/dateTime",
    "$top": 1000,  
    "$select": "id,subject,start,end,location,recurrence,seriesMasterId"
}

# Endpoint to fetch all events (including recurrence details)
events_url = f"https://graph.microsoft.com/v1.0/users/{username}/events"

response = requests.get(events_url, headers=headers, params=params)

if response.status_code == 200:
    events = response.json()
    print("Fetched Events:")
    for event in events["value"]:
        print(f"Subject: {event['subject']}")
        print(f"Start: {event['start']['dateTime']}")
        print(f"End: {event['end']['dateTime']}")
        print(f"Location: {event['location']['displayName']}")
        # Recurrence might not be present for occurrences, so check for it on the seriesMasterId
        if "recurrence" in event:
            print(f"Recurrence: {event['recurrence']}")
        elif "seriesMasterId" in event:
            print(f"Event is part of a recurring series (Series ID): {event['seriesMasterId']}")
        else:
            print("Recurrence: None")
        print("--------------------------------------------------")
else:
    print(f"Error: {response.status_code}")
    print(response.json())

If still the issue persists, check the below:

  • Make use of /calendarView endpoint instead of /events. Refer this SO Thread by Slipstream.
  • Make sure to pass different values for Filter_Start_Date and Filter_Start_Date.
  • Try to handle pagination if the result contains more than 1000 events.
Recognized by Microsoft Azure Collective

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật