You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Kevin H.27
9 years agoNew member | Level 1
BadResponseException: Bad JSON
Dear Dropbox Community,
I am using the Dropbox API v2 for my Android app. Lately I have been seeing issues when trying to download a file with client.files().download() where the file does not (yet) exist. Instead of the expected DownloadErrorException, I am getting a BadResponseException (full stack below). I am using the SDK as in compile 'com.dropbox.core:dropbox-core-sdk:2.0.2'
Any ideas?
com.dropbox.core.BadResponseException: Bad JSON: No suitable constructor found for type [simple type, class com.dropbox.core.DbxRequestUtil$ErrorWrapper$ApiErrorResponse<com.dropbox.core.v2.files.DownloadError>]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: buffer(com.android.okhttp.internal.http.HttpConnection$ChunkedSource@87dfad0).inputStream(); line: 1, column: 2]
at com.dropbox.core.v2.DbxRawClientV2$2.execute(DbxRawClientV2.java:157)
at com.dropbox.core.v2.DbxRawClientV2$2.execute(DbxRawClientV2.java:129)
at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:238)
at com.dropbox.core.v2.DbxRawClientV2.downloadStyle(DbxRawClientV2.java:129)
at com.dropbox.core.v2.files.DbxUserFilesRequests.download(DbxUserFilesRequests.java:258)
at com.dropbox.core.v2.files.DbxUserFilesRequests.download(DbxUserFilesRequests.java:284)
at com.podcatcher.deluxe.model.sync.dropbox.DropboxPodcastListSyncController$DropboxSyncPodcastListTask.getServerSubscriptions(DropboxPodcastListSyncController.java:187)
at com.podcatcher.deluxe.model.sync.dropbox.DropboxPodcastListSyncController$DropboxSyncPodcastListTask.doInBackground(DropboxPodcastListSyncController.java:104)
at com.podcatcher.deluxe.model.sync.dropbox.DropboxPodcastListSyncController$DropboxSyncPodcastListTask.doInBackground(DropboxPodcastListSyncController.java:88)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.dropbox.core.DbxRequestUtil$ErrorWrapper$ApiErrorResponse<com.dropbox.core.v2.files.DownloadError>]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: buffer(com.android.okhttp.internal.http.HttpConnection$ChunkedSource@87dfad0).inputStream(); line: 1, column: 2]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1130)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:298)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2863)
at com.dropbox.core.DbxRequestUtil$ErrorWrapper.fromResponse(DbxRequestUtil.java:273)
at com.dropbox.core.v2.DbxRawClientV2$2.execute(DbxRawClientV2.java:152)
... 13 more
- Greg-DBDropbox Staff
Thanks for the report! I can't seem to reproduce this issue. Can you let me know about when you started seeing it, and about what percent of calls fail like this, to the best of your knowledge? Does it only happen for certain file paths? Thanks in advance!
- Kevin H.27New member | Level 1
Gergory, thanks for your reply!
I have a podcast app which has multiple variants, all using the "App folder" permission. I see this problem consistently now for all the variants and I think that the same code worked last week. My steps are quite simple:
0. Unlink app and delete app folder to reset
1. Connect app using the AuthActivity
2. Try to download "/Subscriptions.txt" with client.files().download()From the debugging I can see that the correct request is send and that the server returns a status code of 409 (probably okay since the file does not yet exist). The Dropbox SDK then tries to parse the response body as a JSON, and fails since it is empty. This results in a BadResponseException instead of the DownloadErrorException I am expecting. If I try the same query from the API Explorer, I get the correct answer:
{ "error_summary": "path/not_found/..", "error": { ".tag": "path", "path": { ".tag": "not_found" } } }
- Greg-DBDropbox Staff
Thanks for following up. So, it sounds like you're seeing it for 100% of your calls to client.files().download()? Are other methods also failing, or are they working properly?
I still can't seem to reproduce this though, even with the additional conditions you mentioned. Are your users seeing this issue too, or is it only happening for you?
- Kevin H.27New member | Level 1
Yes, I see this behaviour for 100% of my calls, if the file requested to download does not exist. If it does, everything works fine. All other calls I use also work fine.
As for users, I have no reports yet. But you could easily try it yourself, simply get my "Simple Podcatcher" app from Google Play and try to syncing via Dropbox. If you connect your device via adb, you should be able to see the error message.
Thanks for your help!
- Greg-DBDropbox Staff
Thanks Kevin, that's helpful. I can reproduce the error using your app. Can you share the relevant code snippet(s)? We'll need to reproduce this separately, and there may be something different between your implementation and mine.
- Kevin H.27New member | Level 1
Sure, my app is Open Source. Please visit https://github.com/salema/Podcatcher-Deluxe-Android-Studio/blob/master/app/src/main/java/com/podcatcher/deluxe/model/sync/dropbox/DropboxPodcastListSyncController.java to see the code, the relevant bit for the error starts at line 182, method getServerSubscriptions()
Thanks for taking the time to look into this!
- Greg-DBDropbox Staff
That's very useful, thanks! We're looking into it.
- Greg-DBDropbox Staff
Based on our investigation, you should be able to work around this issue by adding the following rule to your ProGuard configuration:
-keepclassmembers class com.dropbox.core.** { @com.fasterxml.jackson.annotation.JsonCreator *; }
We'll be addressing this issue in general in a future update of the SDK itself.
- Kevin H.27New member | Level 1
Thanks Gregory, that does the trick. I was following the ProGuard documentation on the SDK's website, so I ruled it out as a reason for this issue. Thanks for getting me back on track!
- Greg-DBDropbox Staff
We have a new release, v2.0.3, that should fix this issue in the SDK itself, so that you'd no longer need that extra ProGuard configuration as a workaround:
https://github.com/dropbox/dropbox-sdk-java/releases/tag/v2.0.3
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,884 PostsLatest Activity: 6 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!