Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions backend/python/app/sources/external/microsoft/one_note/one_note.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import json
import logging
from dataclasses import asdict
Expand Down Expand Up @@ -7395,38 +7393,46 @@ async def me_onenote_notebooks_section_groups_sections_update_pages_content(
"""
# Build query parameters including OData for OneNote
try:
# Use typed query parameters
query_params = RequestConfiguration()
# Construct query parameters and config with a single RequestConfiguration instance
config = RequestConfiguration()
query_params = config # Use config directly for both headers and query_parameters

# Set query parameters using typed object properties
if select:
query_params.select = select if isinstance(select, list) else [select]
config.select = select if isinstance(select, list) else [select]
if expand:
query_params.expand = expand if isinstance(expand, list) else [expand]
config.expand = expand if isinstance(expand, list) else [expand]
if filter:
query_params.filter = filter
config.filter = filter
if orderby:
query_params.orderby = orderby
config.orderby = orderby
if search:
query_params.search = search
config.search = search
if top is not None:
query_params.top = top
config.top = top
if skip is not None:
query_params.skip = skip
config.skip = skip

# Create proper typed request configuration
config = RequestConfiguration()
config.query_parameters = query_params
# Set headers if present

if headers:
config.headers = headers
config.headers = headers.copy() # avoid accidental input mutation

# Add consistency level for search operations in OneNote

# Add consistency level for search operations in OneNote
if search:
if not config.headers:
if not getattr(config, 'headers', None):
config.headers = {}
config.headers['ConsistencyLevel'] = 'eventual'

response = await self.client.me.onenote.notebooks.by_notebook_id(notebook_id).section_groups.by_section_group_id(sectionGroup_id).sections.by_onenote_section_id(onenoteSection_id).pages.by_onenote_page_id(onenotePage_id).content.put(body=request_body, request_configuration=config)
# Make the async PUT request
response = await self.client.me.onenote.notebooks.by_notebook_id(notebook_id)\
.section_groups.by_section_group_id(sectionGroup_id)\
.sections.by_onenote_section_id(onenoteSection_id)\
.pages.by_onenote_page_id(onenotePage_id)\
.content.put(body=request_body, request_configuration=config)

return self._handle_onenote_response(response)
except Exception as e:
return OneNoteResponse(
Expand Down