簡體   English   中英

創建事件時返回“java.lang.ClassCastException”

[英]"java.lang.ClassCastException" is returned when creating events

我正在嘗試使用 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,而不是舊版本。 即使它可能是一個錯誤或回歸,這可能已在以后的版本中修復。 這就是為什么我總是使用最新的 SDKs/builds,看看你是否可以重現這個問題。 很高興您嘗試過並且對您有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM