OneDrive / onedrive-sdk-android

OneDrive SDK for Android!
https://dev.onedrive.com
Other
148 stars 52 forks source link

Uploading of file failed #85

Closed OlegRy closed 8 years ago

OlegRy commented 8 years ago

I've authorized through SDK in my application and now I want upload file from device to OneDrive. I have permissions : "onedrive.readwrite", "onedrive.appfolder" , "wl.offline_access". There's a method for uploading:

public void importFile(File file) {
        if (mClient == null) return;
        Item result = mClient.getDrive().getSpecial("approot")
                .getChildren()
                .byId(file.getName())
                .getContent()
                .buildRequest()
                .put(FileUtil.convertToByteArray(file));
}

This method generates request URL like this: https://api.onedrive.com/v1.0/drive/special/approot/children/myFile.jpg/content and I catch an Exception with next stacktrace: ` FATAL EXCEPTION: IntentService[SyncApiService] Process: com.rcd.perfecto, PID: 4368 com.onedrive.sdk.http.OneDriveServiceException: Error code: Unable to parse error response message Error message: Raw error: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>OneDrive

Our services aren't available right now

We're working to restore all services as soon as possible. Please check back soon.

Ref A: AD2DA6DF3ABB4DD19E05CC6B90E54421 Ref B: 53064A99C83854E658132D84D757A7DB Ref C: Wed Jun 01 09:00:06 2016 PST

                                                            PUT https://api.onedrive.com/v1.0/drive/special/approot/children/PANO_20160524_154957.jpg/content
                                                            X-RequestStats : SDK-Version=Android-v1.1.3
                                                            Authorization : bearer EwCIAq1DBAAUGCCXc8wU/zFu9Qn[...]
                                                            byte[1888628] {-1, -40, -1, -31, 1, 111, 69, 120, [...]

                                                            503 : Service Unavailable
                                                            [...]

                                                            [Some information was truncated for brevity, enable debug logging for more details]
                                                                at com.onedrive.sdk.http.DefaultHttpProvider.handleErrorResponse(DefaultHttpProvider.java:329)
                                                                at com.onedrive.sdk.http.DefaultHttpProvider.sendRequestInternal(DefaultHttpProvider.java:243)
                                                                at com.onedrive.sdk.http.DefaultHttpProvider.send(DefaultHttpProvider.java:154)
                                                                at com.onedrive.sdk.http.BaseStreamRequest.send(BaseStreamRequest.java:98)
                                                                at com.onedrive.sdk.generated.BaseItemStreamRequest.put(BaseItemStreamRequest.java:68)
                                                                at com.rcd.perfecto.utils.storages.helpers.OneDriveHelper.importFile(OneDriveHelper.java:100)
                                                                at com.rcd.perfecto.utils.storages.helpers.StoragesHelper.importFile(StoragesHelper.java:438)
                                                                at com.rcd.perfecto.utils.storages.helpers.StoragesHelper.importFilesIfExist(StoragesHelper.java:104)
                                                                at com.rcd.perfecto.services.SyncApiService.importFilesToClouds(SyncApiService.java:1078)
                                                                at com.rcd.perfecto.services.SyncApiService.uploadNewFilesSync(SyncApiService.java:922)
                                                                at com.rcd.perfecto.services.SyncApiService.startFileSync(SyncApiService.java:859)
                                                                at com.rcd.perfecto.services.SyncApiService.handleActionFullSync(SyncApiService.java:251)
                                                                at com.rcd.perfecto.services.SyncApiService.onHandleIntent(SyncApiService.java:212)
                                                                at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                at android.os.Looper.loop(Looper.java:135)
                                                                at android.os.HandlerThread.run(HandlerThread.java:61)`

I've tried send the same request through apigee.com and all works fine. So what am I doing wrong?

skvalex commented 8 years ago

@OlegRy you need to update SDK up to the version 1.2.0: https://github.com/OneDrive/onedrive-sdk-android/issues/79#issuecomment-221688250

peternied commented 8 years ago

@OlegRy Please reopen if this is still an issue.