Javier171296
Javier171296

Reputation: 49

how to make a successful connection to OneNote api using c#

I read the OneNote Api Documentation https://dev.onenote.com/docs

But I don´t understand how to make a request to the OneNote API with c# web application in order to get all the pages in my OneNote.

I already got the Application Id, Application Secret Id and Redirect URL, but i don´t know where do I have to use them, because I have never done and http request and the documentation only provide the following: https://www.onenote.com/api/v1.0/me/notes/pages, so I don´t know how to send the id´s, redirect url and Authorization: Bearer.

Could you provide me the specific code to get a successful connection to OneNote API using Application Id, Application Secret Id and Redirect URL. And the code structure to make a http request in order to get all the pages, notebooks, etc

I would appreciate if you could help me with this.

Upvotes: 1

Views: 4214

Answers (4)

Javier171296
Javier171296

Reputation: 49

Thank you everyone I have Checked all the links that you provided me and they were very useful, I did a connection to Microsoft Graph with the authorization token and I got access to my OneNote pages.

Thank you for your help.

Upvotes: 0

Marc LaFleur
Marc LaFleur

Reputation: 33094

I would recommend using Microsoft Graph instead of the standalone OneNote API. Microsoft Graph includes support for OneNote. There is also an SDK for .NET available. There are also code samples for ASP.NET, UWP and Xamarin.

Before you can use the Graph API (or most any REST API for that matter), you will need to obtain an authorization token (i.e. the bearer token you referred to in your question). There are libraries available for simplifying this process. Behind the scenes, these libraries are executing an OAUTH 2.0 flow. You can read about what is going on under the covers here.

Upvotes: 2

Jorge Aguirre
Jorge Aguirre

Reputation: 2857

I believe the easiest way to understand these concepts is to look at sample code that does authentication. I recommend this sample:

https://github.com/OneNoteDev/MsGraph_OneNoteApiSampleAspNetCore

Btw - the demo is here: https://onenoteapisamplegraph.azurewebsites.net

Upvotes: 0

user4592495
user4592495

Reputation:

I believe the link they have on the OneNote Dev page is broken. The team has put together a public repository that contains a bunch of sample code in a myriad of languages including C#.

  1. This is the main repo
  2. Web API (ASP.NET Core) Repo

Upvotes: 1

Related Questions