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));
}
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?
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:
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'>
Our services aren't available right now
We're working to restore all services as soon as possible. Please check back soon.
I've tried send the same request through apigee.com and all works fine. So what am I doing wrong?