Created by Microsoft Corporation, 2016. Provided as-is without warranty. Trademarks mentioned here are the property of their owners.
The following aspects of the API are covered in this sample.
- Obtain an access token using Azure PowerShell
- GET all your existing class notebooks
- POST a new class notebook
- POST a new student to an existing class notebook
- POST a new co-teacher to an existing class notebook
- DELETE an existing student from an existing class notebook
- DELETE an existing co-teacher from an existing class notebook
- Azure PowerShell - used to obtain an access token to talk to the OneNote Class Notebooks API.
- An Office 365 account with OneDrive set up - the class notebook that this sample script creates will be located in your OneDrive. To ensure that your OneDrive is set up, log on to Office 365 and click the blue "OneDrive" icon in the app launcher. If you are taken to your OneDrive, you are all set.
- Four additional Office 365 accounts - this sample script will add students and co-teachers to the class notebook it creates using these accounts.
- Obtain a client ID as described under Authenticate using Azure AD (enterprise apps). When asked for a redirect URI, "http://localhost" will suffice:
When asked for OneNote delegated permissions, check the following:
-
Download this repo as a ZIP file to your local computer, and extract the files. Or, clone the repository into a local copy of Git.
-
Edit OneNoteClassNotebooksApiSample.ps1. Find and replace the following tokens with real values:
- <AZURE_AD_TENANT_NAME> - This is your Azure tenant, e.g. "contoso.com".
- <CLIENT_ID> - This is the client ID of your app, e.g. "471afe29-4aee-4bc5-9aaf-468ee5bbe20a".
- <REDIRECT_URI> - This is the redirect URI of your app, e.g. "http://localhost".
- <MY_LOGIN> - This is your Office 365 login name. You will be added as the teacher to the class notebook this script creates.
- <COTEACHER_LOGIN> - This is the Office 365 login name for an account that will be added as a co-teacher to the class notebook this script creates.
- <STUDENT_1_LOGIN>, <STUDENT_2_LOGIN>, <STUDENT_3_LOGIN> - These are the Office 365 login names for accounts that will be added as students to the class notebook this script creates.
-
Once all the placeholders above have been replaced with real values (remember to enclose each value in double quotes), simply execute the script.
-
Once the script has successfully executed, go to your OneDrive where you will see a folder named "Class Notebooks". In this folder you will find the "Math 101" class notebook this script created.
This sample script demonstrated creating a class notebook in your personal OneDrive. If you are an IT administrator, you can also programmatically create class notebooks for teachers. Refer to the Construct the request URI section, in particular the Shared notebooks on OneDrive for Business section. Specifically, you would issue the create request to:
POST https://www.onenote.com/api/v1.0/users/<teacher_id>/notes/classnotebooks
where <teacher_id> is the Office 365 login name of the teacher you wish to create a class notebook for.
Note that before creating class notebooks for teachers, an IT administrator needs to ensure OneDrive is provisioned and access is granted (IT administrators do not have access to users' OneDrives by default). These [OneDrive for Business setup cmdlets] (https://github.com/OneNoteDev/OneDriveForBusiness-SetupPowerShellCmdlets) should come in handy
This is the initial public release for this code sample.
- Learn about OneNote Class Notebooks
- Learn about the OneNote Class Notebooks API
- Visit the dev.onenote.com Dev Center
- Contact us at onenoteedu@microsoft.com
- Follow us on Twitter @onenotedev
- Read our OneNote Developer blog
- Debugging / Troubleshooting