I am getting this error. com.microsoft.graph.core.ClientException: Error executing the request.

Afzal Ghani 0 Reputation points
2024-06-11T06:58:43.92+00:00

I am trying to access an email box with the help of Graph API. but the issue is without a proxy I can hit the request. On my local env, everything works fine when I run this without proxy. But when I add the proxy and then run it fails and gives the error com.microsoft.graph.core.ClientException: Error executing the request.

I am attaching my code which I use please help me.

ProxyOptions proxyOptions =
    new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));

NettyAsyncHttpClientBuilder customHttpClientBuilder =
    new NettyAsyncHttpClientBuilder().proxy(proxyOptions);//Authentication is not required for the proxy

TokenCredential tokenCredential =
    new ClientSecretCredentialBuilder()
        .clientId(clientID)
        .clientSecret(secretValue)
        .tenantId(tenantId)
        .httpClient(customHttpClientBuilder.build())
        .build();


IAuthenticationProvider authProvider =
    new TokenCredentialAuthProvider(
        Arrays.asList("https://graph.microsoft.com/.default"), tokenCredential);

GraphServiceClient<Request> graphClient =
    GraphServiceClient.builder().authenticationProvider(authProvider).buildClient();
String userEmail = "xyz.com";

MessageCollectionPage messages = graphClient.users(userEmail).messages().buildRequest().get();// Code breaks on this line

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,126 questions
0 comments No comments
{count} votes