504 - Gateway Timeout - OneNote Microsoft Graph API

Arpit Shah 26 Reputation points
2023-07-06T14:44:28.56+00:00

The below graph endpoint is used to get sections from notebook for given group.

GET- https://graph.microsoft.com/v1.0/groups/{group-id}/onenote/notebooks/{notebook-id}/sections

(https://learn.microsoft.com/en-us/graph/api/section-get?view=graph-rest-1.0&tabs=http)

We are getting 504 Gateway timeout with Error code UnknownError, while getting section data from onenote group.

Below is the sample response.

Response:

Gateway Timeout - {"error":{"code":"UnknownError","message":"","innerError":{"date":"2023-07-05T12:46:54","request-id":"3b3a998f-0787-4b3d-bd0d-892676890b5c","client-request-id":"c3413d23-05bf-46f3-b019-44a214496c5c"}}}

We have noticed significant increase of this error in recent days(last 2 weeks) for multiple tenants. Knowing what is causing this error and how to fix it will be a great help.

OneNote
OneNote
A family of Microsoft products that enable users to capture, organize, and reuse notes electronically.
180 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,435 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 40,236 Reputation points
    2023-07-07T09:30:59.8866667+00:00

    Hi @Arpit Shah

    Gateway timeout errors are usually server errors caused by MS Graph's request to the upstream server not getting a timely response. To improve operation response time, use $select to specify the exact properties you need and use $top to paginate the returned pages:

    https://graph.microsoft.com/v1.0/groups/{group-id}/onenote/notebooks/{notebook-id}/sections?$select=id,displayName,createdBy&$top=10
    

    Hope this helps.

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


  2. Azechi Akira 0 Reputation points
    2023-07-10T09:57:54.23+00:00

    I've been having the same problem since the end of June.

    In my case, the request below also gives a 504 error.

    GET - https://graph.microsoft.com/v1.0/users/{userPrincipalName}/onenote/notebooks/{notebook-id}/sections

    I've been running the same process for a long time, but suddenly an error started to occur at the end of June. So far, I've had no problems with exactly the same process.

    Also, there are user accounts that have errors and accounts that do not, but even if there are no errors, the API response will be very slow.

    I tried the above countermeasure (adding $select etc.), but the same error occurred and there was no effect.

    After checking a few things, I found that

    If you do not specify a {notebook-id} like /onenote/sections", an error will not occur and the processing result will be returned.

    but,

    If you specify a {notebook-id} like /onenote/notebooks/{notebook-id}/sections, an error will occur with or without $select.

    Prior to the end of June, the same process/same account did not have this problem. From the above answers, it seems that there is some kind of problem on the upstream server side. Please let me know what workaround I should take until this issue is addressed.