Ich bekomme folgende Ausnahme beim Hochladen von Datei zu Dropbox mit Java API.
com.dropbox.core.DbxException$BadRequest: {"error": "OAuth 2 \"Authorization\" header is not well-formed."}
at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:207)
at com.dropbox.core.DbxClient$SingleUploader$1.handle(DbxClient.java:765)
at com.dropbox.core.DbxClient$SingleUploader$1.handle(DbxClient.java:761)
at com.dropbox.core.DbxRequestUtil.finishResponse(DbxRequestUtil.java:279)
at com.dropbox.core.DbxClient$SingleUploader.finish(DbxClient.java:761)
at com.dropbox.core.DbxClient.finishUploadFile(DbxClient.java:629)
at com.dropbox.core.DbxClient.uploadFile(DbxClient.java:562)
at com.dropbox.core.DbxClient.uploadFile(DbxClient.java:514)
folgende ist mein Code
public DbxClient authDropbox(String authAccessToken)throws IOException, DbxException {
DbxRequestConfig dbxRequestConfig = new DbxRequestConfig("JavaDropboxTutorial/1.0", Locale.getDefault().toString());
dbxClient = new DbxClient(dbxRequestConfig, authAccessToken);
return dbxClient;
}
public String uploadToDropbox(String filePath,String fileName,String folderName,DbxClient dbxClient) throws DbxException,IOException {
String sharedUrl;
File inputFile = new File(filePath);
FileInputStream fis = new FileInputStream(inputFile);
try {
dbxClient.uploadFile("/"+folderName+"/"+ fileName,DbxWriteMode.add(), inputFile.length(), fis);
sharedUrl = dbxClient.createShareableUrl("/"+folderName +"/"+fileName);
} finally {
fis.close();
}
return sharedUrl;
}
Datei-Upload-Code