Graph API: Notes - List Pages Doesn't Support $count as Path Segment?

Sean DeNigris 1 Reputation point
2022-12-09T20:03:26.307+00:00

Starting with the Notes - List Pages doc, I see that:

GET /me/onenote/pages… supports the OData Query Parameters

Following that link and scrolling down to the $count documentation, I read that:

$count can be used… as a URL segment to retrieve only the integer total of the collection. For example, users/$count.

However, when I GET https://graph.microsoft.com/v1.0/me/onenote/pages/$count, Graph returns a 400 error.

Is this supposed to work? If so, what might I be doing wrong? If not, how would I have been able to tell without resorting to trial and error (e.g. am I missing something in the docs)?

The only way I found to get the count was (N.B. $top=0 -> 500 error):
GET https://graph.microsoft.com/v1.0/me/onenote/pages?$top=1&$count=true

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,228 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Shivam Dhiman 6,056 Reputation points
    2022-12-10T00:13:11.463+00:00

    Hi @19133679

    To get the pages to count you need to use GET https://graph.microsoft.com/v1.0/me/onenote/pages?$count=true when you are using the above Graph API it's expecting page-id to get that page. Please refer to this documentation. To specify you are using a query parameter you need to use ?$count=true in this case.

    $top=0 is giving you an error because as per the documentation the minimum value of $top is 1 and the maximum depends on the corresponding API.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.


  2. Zehui Yao_MSFT 5,861 Reputation points
    2022-12-12T09:31:32.19+00:00

    Hi @Sean DeNigris , you can request an update to the content of the documentation by posting your ideas at the following support link: https://feedbackportal.microsoft.com/feedback/forum/ebe2edae-97d1-ec11-a7b5-0022481f3c80
    which will be monitored by Microsoft team and make the enhancements to Microsoft Graph APIs. I will also upvote for you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.