Closed kumaraish closed 7 years ago
Hi @kumaraish - thank you for reporting this issue. I'll be investigating this today, and will report back with a status
@kumaraish - I was able to reproduce this issue, and can confirm there is a bug with the library. I will see that this issue is entered into our bug tracker, and is addressed in future builds.
Additionally, two things worth calling out:
Content-Type: application/json
header to files suffixed with .json
. This causes the response body to fail coercion into an InputStream
because this code path is taken instead of this one. In its current form, the msgraph-sdk-android
expects all /content
requests to return a stream, although [as you've discovered] this is clearly not correct 100% of the time. As there is currently no available fix or workaround for this I suggest either renaming the file or falling back to REST/HTTP.DriveItem
, you may use the following syntaxInputStream is = mGraphServiceClient
.getMe()
.getDrive()
.getItems()
.byId("<your id here>")
.getContent()
.buildRequest()
.get();
@iambmelt Thanks for the update. Could you please comment on if there is any advantage of doing .getItems().byId("<your id here>").getContent()
over .getItems("<your id here>").getContent()
. Either of them seems to work fine.
On a side note, as a temporary workaround for downloading json files from OneDrive, I am using @microsoft.graph.downloadUrl
returned as part of the DriveItem metadata.
@kumaraish Apologies for the confusion; if both appear to be working acceptably (Content-Type
bug aside), then feel free to use either. In my testing I had tried your sample code (thanks for providing this, btw) - saw it fail, then continued testing with an alternative implementation (matching my desc). I'll modify the above post to reflect this syntax as alternative.
Thank you for providing your workaround solution as well.
Closing this issue.
The current recommended pattern to download JSON from OneDrive is to request the DriveItemMetadata
and perform a GET
to the payload's @microsoft.graph.downloadUrl
property
Using the following code to download a .json file from OneDrive throws exception -
Exception thrown -