Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Wilson Jan S.'s avatar
Wilson Jan S.
New member | Level 1
10 years ago

Cannot commit chunk upload. Returns 400 always.

Whenever I commit the chunk upload supplying the access_token and upload_id, it always return an error code 400.

Here is the code.

private boolean commitChunk(String upload_id, String path){
int responseCode = 0;
try {
URL url = new URL("https://content.dropboxapi.com/1/commit_chunked_upload/auto/" + path);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("Authorization", "Bearer " + access_token_here);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes("upload_id=" + upload_id);
wr.flush();
wr.close();
responseCode = connection.getResponseCode();
System.out.println("response code: " + responseCode);
if(responseCode == 200){
connection.disconnect();
return true;
}
} catch (Exception exception) {
LogService.info(exception.getMessage());
System.out.println("Exception: " + exception.getMessage());
}
return false;

}

}

 

NOTE: I cannot use Dropbox SDK, and limited to Java1.4 only. So I can only do manual HTTP methods.

3 Replies

Replies have been turned off for this discussion
  • Wilson Jan S.'s avatar
    Wilson Jan S.
    New member | Level 1
    10 years ago

    Sorry, I already found the problem. I didn't specify a filename. My bad. Sorry. The response body was Bad Request. Thanks for the support Mr. Steve. :)

  • Just for future debugging, "Bad Request" is the status line. The actual body of the response should contain an error message that probably said something about a missing parameter. :-)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If 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, Facebook or Instagram.

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!