Microsoft graph Api : While tring to download file from onedrive through graph api , It is throwing ClientException.

Venktesh Birla 1 Reputation point
2021-03-05T04:33:28.947+00:00

We are trying to download one file from onedrive file using the following endpoint call through microsoft graph api https://graph.microsoft.com/v1.0/me/drive/items/012HV4LEMQTONTSFH3KZA3RUPLOCHKHIV4/content But getting the following exception : com.microsoft.graph.core.ClientException: Error during http request at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:422) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:204) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:184) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:306) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.http.CustomRequest.get(CustomRequest.java:43) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.automationanywhere.botcommand.onedrive.commands.DownloadDriveItem.execute(DownloadDriveItem.java:116) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.automationanywhere.botcommand.onedrive.commands.DownloadDriveItemCommand.execute(DownloadDriveItemCommand.java:80) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.automationanywhere.botrunner.bot.Bot_Content.executeNode18(Bot_Content.java:335) ~[?:?] at com.automationanywhere.botrunner.bot.Bot_Content.play(Bot_Content.java:444) ~[?:?] at com.automationanywhere.botrunner.Main.play(Main.java:63) ~[?:?] at com.automationanywhere.botengine.service.impl.BotLauncherImpl.runBot(BotLauncherImpl.java:22) ~[bot-launcher.jar:?] at com.automationanywhere.botengine.service.impl.DispatcherImpl.lambda$start$8(DispatcherImpl.java:358) ~[bot-launcher.jar:?] at com.automationanywhere.botengine.utils.ThreadUtil.lambda$withThreadContext$0(ThreadUtil.java:20) ~[bot-launcher.jar:?] at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?] at java.lang.Thread.run(Unknown Source) [?:?] Caused by: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close() at okhttp3.internal.connection.RealCall.enterNetworkInterceptorExchange(RealCall.kt:229) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:66) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.httpcore.TelemetryHandler.intercept(TelemetryHandler.java:37) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.httpcore.RedirectHandler.intercept(RedirectHandler.java:123) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.httpcore.RetryHandler.intercept(RetryHandler.java:140) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.httpcore.AuthenticationHandler.intercept(AuthenticationHandler.java:31) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:356) ~[bot-command-onedrive-2.2.0-20210127-131519.jar:?] ... 16 more I am using this api from long time in our project and it was working fine. We have not done any changes recently , but we start getting the exception from last 1-2 days. Please help us to resolve this issue. Thanks

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

2 answers

Sort by: Most helpful
  1. Venktesh Birla 1 Reputation point
    2021-04-05T11:28:11.497+00:00

    We did more analysis from our side and mentioned the same below.

    We are using microsoft graph version 1.7.1 jar to download file from onedrive. The jar using by default version 3.12.1 of com.squareup.okhttp3 .

    But this version(3.12.1) has some vulnerability , hence we overridden default version of com.squareup.okhttp3 to "4.8.0" 6-8 months back . With this new version of com.squareup.okhttp3 , microsoft graph services was working fine , but from some time back , suddenly it start throwing this error/exception.

    Then I tried to revert back version of com.squareup.okhttp3 means from "4.8.0" to default("3.12.1") , "download file from onedrive" service start working again.

    It seems that "4.8.0" version of com.squareup.okhttp3 is not compactible with microsoft graph version 1.7.1 for some of rest service like "download file from onedrive", "export pdf from onedrive" etc.

    Please look into this issue asap. It has blocked some of our urgent deliverables.

    Thanks for understanding.

    0 comments No comments

  2. Pawar Shubham 1 Reputation point
    2022-12-30T06:54:03.453+00:00

    Hi,

    I am getting same error when i upload file in Sharepoint online location using MS graph SDK. I have uploaded same error in below link.
    https://learn.microsoft.com/en-us/answers/questions/1119524/not-able-to-upload-file-in-sharepoint-online-using.html

    please let me know if you find any solution. i am also trying to upload in AWS VM. same code works local machine. but not in AWS

    0 comments No comments