public async Task OneNoteListPages() { try { IOnenotePagesCollectionPage pageCollection = await graphClient.Me .Onenote .Pages .Request() .GetAsync(); Assert.True(pageCollection.Count > 0); Assert.NotNull(pageCollection[0].Id); } catch (Microsoft.Graph.ServiceException e) { Assert.True(false, $"Error code: {e.Error.Code}"); } catch (Exception e) { Assert.True(false, $"Error code: {e.Message}"); } }
public async Async.Task OneNoteListPages() { try { IOnenotePagesCollectionPage pageCollection = await graphClient.Me .Onenote .Pages .Request() .GetAsync(); Assert.IsTrue(pageCollection.Count > 0, $"Expected at least one Page; Actual {pageCollection.Count}"); Assert.IsNotNull(pageCollection[0].Id, "Expected an ID value; ID value is missing."); } catch (Microsoft.Graph.ServiceException e) { Assert.Fail("Error code: {0}", e.Error.Code); } catch (Exception e) { Assert.Fail("Error code: {0}", e.Message); } }
/// <summary> /// Gets the OneNote pages of the user authenticated with GraphServiceClient. /// </summary> /// <param name="client">An authenticated GraphServiceClient containing the user's access token.</param> /// <returns>The list of pages owned by the user.</returns> public static async Task <List <OnenotePage> > GetMyPages(GraphServiceClient client) { IOnenotePagesCollectionPage results = await client.Me.Onenote.Pages.Request().GetAsync(); return(results.ToList()); }