microsoftgraph / msgraph-sdk-android

Microsoft Graph SDK for Android! https://graph.microsoft.io
Other
51 stars 43 forks source link

Session base upload stopped working October 25th 2019 #114

Closed gerritbeuze closed 4 years ago

gerritbeuze commented 4 years ago

Since January 2019 I have used this library to upload files to OneDrive using session based upload. Code below. Since October 25th however, this no longer works. The code was unchanged and we have received numerous reports from users that upload fails starting that date.

When checking the Azure portal I found that around that date there was a migration from the old portal to the Azure portal. Could it be that azure does not (yet) support session based uploads? Direct upload ( < 4 MB ) method works OK.

Any idea what's wrong + how to restore the session based upload?

            DriveItemUploadableProperties props = new DriveItemUploadableProperties();
            List<Option> options = new ArrayList<>();
            if (_fileInfo.isNew())
                options.add(new QueryOption("@microsoft.graph.conflictBehavior", "rename"));
            else
                options.add(new QueryOption("@microsoft.graph.conflictBehavior", "replace"));
            String encodedName = OneDrive.buildURLEncodedPath(_fileInfo.name());
            // This excepts with 400, bad request
            UploadSession session = OneDrive.instance().client().getMe().getDrive().getItems(_fileInfo.parentId()).getItemWithPath(encodedName).getCreateUploadSession(props).buildRequest(options).post();
                        // never reaches this
            if (session != null) {
                        }

Here's the detailed log:


E/DefaultHttpProvider[sendRequestInternal] - 333: OneDrive Service exception POST https://graph.microsoft.com/v1.0/me/drive/items/[removed]:/Direct

%20upload%20Conflict%20Copy.smmx:/microsoft.graph.createUploadSession?%40microsoft.graph.conflictBehavior=replace
    SdkVersion : graph-android-v1.7.0
E/DefaultHttpProvider[sendRequestInternal] - 333: Authorization : bearer [removed]
    {"item":{}}
E/DefaultHttpProvider[sendRequestInternal] - 333: 400 : Bad Request
E/DefaultHttpProvider[sendRequestInternal] - 333: X-Android-Selected-Protocol : http/1.1
E/DefaultHttpProvider[sendRequestInternal] - 333: Strict-Transport-Security : max-age=31536000
    Cache-Control : private
    x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"001","RoleInstance":"AGSFE_IN_21"}}
E/DefaultHttpProvider[sendRequestInternal] - 333: client-request-id : [removed]
    X-Android-Response-Source : NETWORK 400
    X-Android-Sent-Millis : 1573630667766
E/DefaultHttpProvider[sendRequestInternal] - 333: request-id : [removed]
    Content-Length : 212
E/DefaultHttpProvider[sendRequestInternal] - 333: X-Android-Received-Millis : 1573630668566
    Date : Wed, 13 Nov 2019 07:37:53 GMT
    Content-Type : application/json
E/DefaultHttpProvider[sendRequestInternal] - 333: {
       "error": {
          "code": "invalidRequest",
E/DefaultHttpProvider[sendRequestInternal] - 333:       "message": "Bad Argument",
          "innerError": {
E/DefaultHttpProvider[sendRequestInternal] - 333:          "request-id": "[removed]",
             "date": "2019-11-13T07:37:53"
E/DefaultHttpProvider[sendRequestInternal] - 333:       }
       }
E/DefaultHttpProvider[sendRequestInternal] - 333: }
E/DefaultHttpProvider[sendRequestInternal] - 333: Throwable detail: 
    com.microsoft.graph.http.GraphServiceException: POST https://graph.microsoft.com/v1.0/me/drive/items/[removed]:/Direct%20upload%20Conflict

%20Copy.smmx:/microsoft.graph.createUploadSession?%40microsoft.graph.conflictBehavior=replace
    SdkVersion : graph-android-v1.7.0
    Authorization : bearer [removed]
    {"item":{}}

    400 : Bad Request
    [...]

    [Some information was truncated for brevity, enable debug logging for more details]
        at com.microsoft.graph.http.DefaultHttpProvider.handleErrorResponse(DefaultHttpProvider.java:357)
        at com.microsoft.graph.http.DefaultHttpProvider.sendRequestInternal(DefaultHttpProvider.java:294)
        at com.microsoft.graph.http.DefaultHttpProvider.send(DefaultHttpProvider.java:190)
        at com.microsoft.graph.http.DefaultHttpProvider.send(DefaultHttpProvider.java:170)
        at com.microsoft.graph.http.BaseRequest.send(BaseRequest.java:272)
        at com.microsoft.graph.generated.BaseDriveItemCreateUploadSessionRequest.post(BaseDriveItemCreateUploadSessionRequest.java:43)
        at [removed].onedrive.OneDriveFileUploader.doInBackground(OneDriveFileUploader.java:77)
        at [removed].onedrive.OneDriveFileUploader.doInBackground(OneDriveFileUploader.java:23)
        at android.os.AsyncTask$2.call(AsyncTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:784)
baywet commented 4 years ago

Hi everyone, Thank you for the contribution, we have moved away from an android specific SDK to a Java SDK and this repo will be archived very soon. If you're still facing the same issue with the Java SDK, feel free to re-open an issue over there. Closing.