Bad JSON in X-Dropbox-Metadata Header

I am using Dropbox JAVA SDK version 1.8.1 for my application. Recently, I have encountered the following error when downloading files using the upload API: Bad JSON in the X-Dropbox-Metadata header: 1.96: \ "photo_info \": waiting for the end of the object (\ "} \") " . I did not request information about media and did not add includeMediaInfo to true. Here is the code snippet:

DbxClient.Downloader downloader = client.startGetFile(folderPath+"/"+filename,"");
InputStream in = downloader.body;
OutputStream outs = response.getOutputStream();
byte buf[] = new byte[10000000];
int len;
while ((len = in.read(buf, 0, 10000000)) != -1) {
 outs.write(buf, 0, len);
}
outs.close();
outs.flush();
in.close();
downloader.close();

Here is the stack trace:

threw exception [com.dropbox.core.DbxException$BadResponse: Bad JSON in X-Dropbox-Metadata header: 1.96: ""photo_info"": expecting the end of an object (""}"")] with root cause" "com.dropbox.core.json.JsonReadException: 1.96: ""photo_info"": expecting the end of an object (""}"")
at com.dropbox.core.json.JsonReader.expectObjectEnd(JsonReader.java:82)
at com.dropbox.core.DbxEntry$File$PhotoInfo$1.read(DbxEntry.java:412)
at com.dropbox.core.DbxEntry$File$PhotoInfo$1.read(DbxEntry.java:393)
at com.dropbox.core.DbxEntry$PendingReader.read(DbxEntry.java:957)
at com.dropbox.core.json.JsonReader.readField(JsonReader.java:30)
at com.dropbox.core.DbxEntry._read(DbxEntry.java:880)
at com.dropbox.core.DbxEntry.read(DbxEntry.java:826)
at com.dropbox.core.DbxEntry$File$1.read(DbxEntry.java:315)
at com.dropbox.core.DbxEntry$File$1.read(DbxEntry.java:310)
at com.dropbox.core.json.JsonReader.readFully(JsonReader.java:386)
at com.dropbox.core.json.JsonReader.readFully(JsonReader.java:292)
at com.dropbox.core.DbxClient.startGetSomething(DbxClient.java:472)
at com.dropbox.core.DbxClient.startGetFile(DbxClient.java:452)

A similar kind of exception is also found in searchAPI. The same piece of code worked fine in the previous version 1.7.7, and I was able to upload the files.

Please help me sort this out. Thanks in advance!

+4

Source: https://habr.com/ru/post/1611936/


All Articles