Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error Code: generalException Message: An error occurred sending the request. with Microsoft Graph Version 4.28 while retrieving Calendar Events #2738

Open
shambhaviQuest opened this issue Nov 11, 2024 · 0 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@shambhaviQuest
Copy link

Describe the bug

                var queryOptions = new List<QueryOption>
                {
                    new QueryOption("startDateTime", startTime.ToString("o")),
                    new QueryOption("endDateTime", endTime.ToString("o"))
                };
                // Get calendar events for the specified user and time window
              var events = await graphClient.Users[email]
                                  .Calendar
                                  .CalendarView
                                  .Request(queryOptions).Top(900)
                                  .GetAsync();

public class GraphAuthenticationProvider : IAuthenticationProvider
{
private readonly IConfidentialClientApplication _clientApp;
private readonly string[] _scopes;
public GraphAuthenticationProvider(string clientId, string tenantId, string clientSecret, string[] scopes)
{
_clientApp = ConfidentialClientApplicationBuilder.Create(clientId)
.WithTenantId(tenantId)
.WithClientSecret(clientSecret)
.Build();
_scopes = scopes;
}

        public async System.Threading.Tasks.Task AuthenticateRequestAsync(HttpRequestMessage request)
        {
            await _clientApp.AcquireTokenForClient(_scopes).ExecuteAsync();
        }
    }

Microsoft Graph( v4.x) is getting authenticated properly but when running the API to get the calendar events using the code given above, I am getting the error : "Code: generalException
Message: An error occurred sending the request."
and "System.AggregateException: One or more errors occurred. ---> Microsoft.Graph.ServiceException: Code: generalException
Message: Unexpected exception returned from the service.
ClientRequestId: 09f6cdf7-ed58-4714-80a6-03c8c6964692"

this error is coming in AuthenticateRequestAsync() method when trying to get the calendar events.

I am using .Net framework version 4.7.2

This is not a problem with Microsoft.Graph dotnet v3.x
This is not a problem with Visual Studio 2019.

Expected behavior

I should be able to get the calendar events with Microsoft Graph version 4.x

How to reproduce

Authenticate the Microsoft graph with version 4.x
try to get the calendar events using the code mentioned above on the .Net framework 4.7.2

SDK Version

4.28

Latest version known to work for scenario above?

3.x

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

- OS: windows server 2019
- architecture: x86

### Other information

_No response_
@shambhaviQuest shambhaviQuest added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

1 participant