Ballerina connector for Microsoft OneNote connects the Microsoft OneNote API through Ballerina. It provides the capability to perform CRUD operations on OneNote notebooks, sections and pages.

This module supports Microsoft Graph API v1.0 version and only allows to perform functions behalf of the currently logged in user.


Before using this connector in your Ballerina application, complete the following:


To use the MS OneNote connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

First, import the ballerinax/microsoft.onenote module as shown below.

import ballerinax/microsoft.onenote;

Step 2: Create a new connector instance

Create a microsoft.onenote:ConnectionConfig with the OAuth2 tokens obtained and initialize the connector with it.

microsoft.onenote:ConnectionConfig configuration = {
    auth: {
        refreshUrl: <REFRESH_URL>,
        refreshToken : <REFRESH_TOKEN>,
        clientId : <CLIENT_ID>,
        clientSecret : <CLIENT_SECRET>

microsoft.onenote:Client oneNoteClient = check new(configuration);

Step 3: Invoke connector operation

Now you can use the operations available within the connector. Note that they are in the form of remote operations.

Following is an example on how to create a notebook using the connector.

public function main() returns error? {
    Notebook notebook = check oneNoteClient->createNotebook("test");

You can find a list of samples here

Other versions

See more...