Im trying to write a script/small app that goes through a notebooks sections, creates a folder on the machine thats running the script for every section and saves the section's pages' html in their respective folder (basically so i can import them to confluence or whatever else).
I cant figure out how to access this data, because im using the code snippets from graph explorer and all im getting is 400 and bad request errors.
Id appreciate some help and maybe some docs on how to leverage the client classes from the msgraph-sdk.
import asyncio
import configparser
from msgraph import GraphServiceClient
from azure.identity.aio import ClientSecretCredential
# Read configuration from .cfg file
config = configparser.ConfigParser()
config.read("config.cfg")
# Get Azure configuration values
azure_config = config["azure"]
client_id = azure_config["clientId"]
tenant_id = azure_config["tenantId"]
secret_id = azure_config["clientSecret"]
credentials = ClientSecretCredential(
tenant_id=tenant_id, client_id=client_id, client_secret=secret_id
)
scopes = ["https://graph.microsoft.com/.default"]
client = GraphServiceClient(credentials=credentials, scopes=scopes)
async def main():
apps = await client.applications.get()
if apps and apps.value:
for app in apps.value:
print(app.display_name)
# Gets registered app name as expected
await client.me.onenote.pages.by_onenote_page_id(
"0-e4480296df44483797a6e9498a27ee08!240-2D4AD3C4F6B959E4!363379",
).content.get()
# 400 Bad request
# msgraph.generated.models.o_data_errors.o_data_error.ODataError:
# APIError
# Code: 400
# message: None
asyncio.run(main())