Transient 405 errors when accessing Worksheets via Graph API v4

Andy Schneider 20 Reputation points
2023-10-26T07:37:49.99+00:00

Hi,

I've inherited a system which has sporadic errors when accessing an Excel spreadsheet on business onedrive via v4 Graph API. I am using the .NET SDK (v4.54.0). The code that often provokes the situation looks like this:

                        await GetDocuplanWorkbook(folderPath, fileName)
                            .Worksheets[sheet.Name]
                            .Range($"{worksheetData.GetExcelLocation(rowNumber, 1)}:{worksheetData.GetExcelLocation(rowNumber, row.Length)}")
                            .Request()
                            .WithRetries(_logger)
                            .PatchAsync(new WorkbookRange
                            {
                                Values = JsonDocument.Parse(JsonSerializer.Serialize(new[] { row })),
                                NumberFormat = JsonDocument.Parse(JsonSerializer.Serialize(new[] { worksheetData.GetColumnsExcelFormat(sheet.ExcelFormatMappings) }))
                            });

When an error occurs (during the day time this is 10-20% of user operations) I get a 405 MethodNotAllowed but no JSON error payload. Instead I get an HTML document returned:








<div><h1>Server Error</h1></div>
<div>
 <div><fieldset>
  <h2>405 - HTTP verb used to access this page is not allowed.</h2>
  <h3>The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.</h3>`
 </fieldset></div>
</div>


The issue always seems to be when using the Range endpoint, e.g.

https://graph.microsoft.com:443/v1.0/users/
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,649 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,457 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,720 questions
0 comments No comments
{count} votes