ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,719 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm currently developing an ASP.NET Core API that interacts with SharePoint via Microsoft Graph. While the setup works occasionally, I'm experiencing significant reliability issues. The API calls to Graph work about 50% of the time and fail the rest of the time without any changes to the code or environment.
public class CustomAuthenticationProvider : IAuthenticationProvider
public CustomAuthenticationProvider(ITokenAcquisition tokenAcquisition)
{
_tokenAcquisition = tokenAcquisition;
}
public async Task AuthenticateRequestAsync(HttpRequestMessage request)
{
string[] scopes = new[] { "https://graph.microsoft.com/.default" };
string accessToken = await _tokenAcquisition.GetAccessTokenForUserAsync(scopes);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
}
}
#### Sample Graph Query:
```csharp
var query = $"fields/Number '{itemId}'";
var page = await _graphServiceClient.Sites[siteId].Lists[listId].Items
.Request()
.Expand("fields")
.Filter(query)
.GetAsync();
The API works sporadically, failing immediately with errors like:
The issue occurs regardless of the size of the SharePoint library:
What I Need Help With