diff --git a/backend/python/app/sources/external/microsoft/one_note/one_note.py b/backend/python/app/sources/external/microsoft/one_note/one_note.py index 76dbc9ad19..a0e310e7a0 100644 --- a/backend/python/app/sources/external/microsoft/one_note/one_note.py +++ b/backend/python/app/sources/external/microsoft/one_note/one_note.py @@ -1,5 +1,3 @@ - - import json import logging from dataclasses import asdict @@ -2725,27 +2723,33 @@ async def groups_onenote_notebooks_section_groups_sections_update_pages_content( """ # Build query parameters including OData for OneNote try: - # Use typed query parameters - query_params = RequestConfiguration() - # Set query parameters using typed object properties - if select: - query_params.select = select if isinstance(select, list) else [select] - if expand: - query_params.expand = expand if isinstance(expand, list) else [expand] - if filter: - query_params.filter = filter - if orderby: - query_params.orderby = orderby - if search: - query_params.search = search - if top is not None: - query_params.top = top - if skip is not None: - query_params.skip = skip - - # Create proper typed request configuration + # Use a single RequestConfiguration object for both headers and query parameters. config = RequestConfiguration() - config.query_parameters = query_params + + # Only allocate and assign query_parameters when necessary + any_query_param = ( + select or expand or filter is not None or orderby is not None or + search is not None or top is not None or skip is not None + ) + if any_query_param: + query_params = RequestConfiguration() + # Set query parameters using typed object properties + if select: + query_params.select = select if isinstance(select, list) else [select] + if expand: + query_params.expand = expand if isinstance(expand, list) else [expand] + if filter is not None: + query_params.filter = filter + if orderby is not None: + query_params.orderby = orderby + if search is not None: + query_params.search = search + if top is not None: + query_params.top = top + if skip is not None: + query_params.skip = skip + + config.query_parameters = query_params if headers: config.headers = headers