0

I am trying to upload file to Dropbox using dropbox java sdk

I created a app in dropbox, gave permission to write, app status is Development.

The code works till "write mode done" logger, it fails after that. fileStream is of type InputStream

DbxClientV2 client = createClient();
    String path = "/" + fileName.toString();
    try {
        System.out.println("STARTING...............");
        UploadBuilder ub = client.files().uploadBuilder(path);
        System.out.println("ub done");
        ub.withMode(WriteMode.ADD);
        System.out.println("write mode done");
        FileMetadata metadata = ub.uploadAndFinish(fileStream);
        System.out.println("File uploaded");
        System.out.println(metadata.toStringMultiline());
        ;
        System.out.println("FINISHED...............");
    } catch (IOException e) {
        e.printStackTrace();
    }

Exception I get is

com.dropbox.core.BadResponseException: Bad JSON: expected object value.
at [Source: ; line: 1, column: 1]
at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:347)
at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:324)
at com.dropbox.core.DbxUploader.finish(DbxUploader.java:268)
at com.dropbox.core.DbxUploader.uploadAndFinish(DbxUploader.java:126)
.
.
.
Caused by: com.fasterxml.jackson.core.JsonParseException: expected object value.
at [Source: ; line: 1, column: 1]
at com.dropbox.core.stone.StoneSerializer.expectStartObject(StoneSerializer.java:91)
at com.dropbox.core.ApiErrorResponse$Serializer.deserialize(ApiErrorResponse.java:53)
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.