创建事件时返回“ java.lang.ClassCastException”

时间:2020-10-07 13:54:07

标签: java sdk microsoft-graph-api

我正在尝试使用Microsoft Graph创建一个事件。 有时我收到ClassCastException,但我不知道为什么 创建事件时返回“响应二进制”的情况是什么?

我的代码是这样的:

display: inline; 

我收到此错误:

ClientCredentialProvider authProvider = new GraphAuthProvider(accessToken);
IGraphServiceClient graphClient = GraphServiceClient
                .builder()
                .authenticationProvider(authProvider)
                .buildClient();

Event event = graphClient
                .users(USER)
                .events()
                .buildRequest(requestOptions)
                .post(event);

添加java.io.BufferedInputStream cannot be cast to com.microsoft.graph.models.extensions.Event" java.lang.ClassCastException: java.io.BufferedInputStream cannot be cast to com.microsoft.graph.models.extensions.Event at com.microsoft.graph.requests.extensions.EventRequest.post(EventRequest.java:112) at com.microsoft.graph.requests.extensions.EventCollectionRequest.post(EventCollectionRequest.java:67) 时:

graphClient.getLogger().setLoggingLevel(LoggerLevel.DEBUG);

看着带有SDK的日志,我猜想如果返回“ Response binary”,则会发生上述错误。 它仅在远程计算机上发生,而我无法在库中进行调试。 创建事件时返回“响应二进制”的情况是什么?

这是我正在使用的库。

Starting to send request, URL https://graph.microsoft.com/v1.0/users/USER/events
com.microsoft.graph.logger.DefaultLogger logDebug
Request Method PATCH
com.microsoft.graph.logger.DefaultLogger logDebug
Sending com.microsoft.graph.models.extensions.Event as request body
com.microsoft.graph.logger.DefaultLogger logDebug
Serializing type Event
com.microsoft.graph.logger.DefaultLogger logDebug
Response code 200, OK
com.microsoft.graph.logger.DefaultLogger logDebug
Response binary
com.microsoft.graph.logger.DefaultLogger logDebug
Deserializing type Event

对不起,我的英语很难理解。 如果您给我答复,将会很有帮助。

1 个答案:

答案 0 :(得分:0)

我建议您仅使用最新的版本/ SDK,而不要使用较早的版本。即使它可能是错误或回归,也可能已在更高版本中修复。这就是为什么我总是使用最新的SDK /内部版本,看看您是否可以解决此问题。很高兴您尝试了它,对您有用。