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..cdf3c3d99a 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 @@ -6302,28 +6300,39 @@ async def me_onenote_notebooks_section_groups_get_parent_section_group( OneNoteResponse: OneNote response wrapper with success/data/error """ # Build query parameters including OData for OneNote + # Build query parameters including OData for OneNote try: - # Use typed query parameters - query_params = NotebooksRequestBuilder.NotebooksRequestBuilderGetQueryParameters() - # 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 + # Only allocate query_params if at least one query parameter is used + has_query = ( + select or expand or filter or orderby or search or + (top is not None) or (skip is not None) + ) + + if has_query: + # Use typed query parameters + query_params = NotebooksRequestBuilder.NotebooksRequestBuilderGetQueryParameters() + # 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 + else: + query_params = None # Create proper typed request configuration config = NotebooksRequestBuilder.NotebooksRequestBuilderGetRequestConfiguration() - config.query_parameters = query_params + if query_params is not None: + config.query_parameters = query_params if headers: config.headers = headers