Graph API Returns 504 Error Even for Single Cell Value Updates

Maxwell Moreira 0 Reputation points
2023-09-04T17:28:04.93+00:00

I'm attempting to update a cell value in an Excel sheet hosted on OneDrive using the Microsoft Graph API. However, every attempt results in a 504 Gateway Timeout error. Below is the code snippet for the PATCH request:

{
  "method": "PATCH",
  "url": "https://graph.microsoft.com/v1.0/me/drive/items/[ITEM_ID]/workbook/worksheets/[WORKSHEET_ID]/range(address='C5')",
  "data": {
    "values": [
      [
        "TODAS AS REGIOES"
      ]
    ]
  },
  "headers": {
    "Authorization": "Bearer [YOUR_TOKEN]",
    "Content-Type": "application/json"
  }
}

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
901 questions
Microsoft Graph Files API
Microsoft Graph Files API
A Microsoft API to create an app that connects with files across OneDrive, OneDrive for Business, and SharePoint document libraries.
390 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 28,196 Reputation points
    2023-09-05T10:32:44.01+00:00

    Hi @Maxwell Moreira

    The "504 Gateway Timeout" is a server-side error. This could be caused by various factors, such as network issues, server overload, or request complexity.

    One possible solution is to reduce the requested page size. If you are using JSON batching for this endpoint, do not merge other requests yet to reduce workload. If a 504 Gateway Timeout error is still returned, try calling the API individually instead of using batching for that endpoint.

    Another possible solution is to retry the request after a certain interval. Sometimes, the 504 error is temporary and can be resolved by resubmitting the request. You could implement a retry logic in your code that checks for the 504 error and waits for a few seconds before trying again.

    If the above suggestions don't work, then please open a support ticket on this to get help from the Microsoft support team.

    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.