java - 创建事件时返回“java.lang.ClassCastException”
问题描述
我正在尝试使用 Microsoft Graph 创建一个事件。有时我会得到一个ClassCastException,但我不知道为什么在创建事件时返回“响应二进制”是什么情况?
我的代码是这样的:
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);
添加:
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
用SDK查看日志,我猜如果返回“Response binary”,就会出现上述错误。它只发生在远程计算机上,我无法在库中调试。创建事件时返回“响应二进制”是什么情况?
这是我正在使用的库。
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>1.7.0</version>
</dependency>
如果我的英语难以理解,我很抱歉。如果你给我答案会很有帮助。
解决方案
我建议您只使用最新的构建/SDK,而不是旧的构建。即使它可能是错误或回归,也可能已在以后的版本中修复。这就是为什么我总是使用最新的 SDK/构建,看看你是否可以重现这个问题。很高兴您尝试了它并且它对您有用。
推荐阅读
- tensorflow - tensorflow 和 CNN 中的可变批量大小
- python - 有没有办法在 python 中指定一个包中所有脚本可用的 BASE_DIR 设置?
- reactjs - 如何在反应中重定向到相应的组件?
- javascript - 如果未选中选项组中的单选按钮,请发出警报?
- javascript - 从纬度和经度获取地址
- machine-learning - 如何在不将新数据与旧数据合并的情况下重新训练我的机器学习模型?
- live-streaming - 跨设备同步 HLS 直播
- oauth-2.0 - 在 Office365 上获取对 EWS 的访问令牌时范围无效
- django - django rest框架默认字段验证的问题
- wpf - WPF KeyBinding 禁用并让键盘快捷键冒泡