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

ksprasad's avatar
ksprasad
New member | Level 2
8 years ago

Unexpected response code 400

Hi,

 

I had been able to successfully connect to dropbox using dropbox api. I am using the bundle dropbox-core-sdk 1.7.6 from maven repository. 

But since recently I am getting the below error from the same code.

 

Caused by: com.dropbox.core.DbxException$BadResponse: unexpected response code: 400
at com.dropbox.core.DbxClient$4.handle(DbxClient.java:274)
at com.dropbox.core.DbxClient$4.handle(DbxClient.java:270)
at com.dropbox.core.DbxRequestUtil.doGet(DbxRequestUtil.java:265)
at com.dropbox.core.DbxClient.doGet(DbxClient.java:1912)
at com.dropbox.core.DbxClient.getAccountInfo(DbxClient.java:270)
at org.apache.camel.dropbox.utils.DropboxApp.connect(DropboxApp.java:42)

 

Any idea what could be going wrong?

 

Below is the code:

final DropboxAppConfiguration appConfig = new DropboxAppConfiguration(appKey, appSecret,
                accessToken, host, port);
        final DropboxApp app = DropboxApp.create(appConfig);
        try {
            client = app.connect();
            logger.debug("Client connected: " + client.getAccountInfo().displayName);
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException(e);
        } catch (final IOException e) {
            throw new IllegalArgumentException(e);
        } catch (final DbxException e) {
            throw new IllegalArgumentException(e);
        }

 

 

Regards,

ksprasad

  • The Dropbox Java SDK you're using (v1.7.6) is old and is using the now retired API v1. Calling API v1 will return a 400 error since it is now disabled.

     

    You should instead use the latest version of the Dropbox Java SDK (currently v3.0.5), which uses API v2.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The Dropbox Java SDK you're using (v1.7.6) is old and is using the now retired API v1. Calling API v1 will return a 400 error since it is now disabled.

     

    You should instead use the latest version of the Dropbox Java SDK (currently v3.0.5), which uses API v2.

    • Asakela's avatar
      Asakela
      New member | Level 2
      I AM not a developer - I am but a humble user. The answer doesn’t give me any clues about remedies to my problem. What can I do to make my connection work again?
      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Asakela This is something the developer of the third party app would need to help with. I recommend you contact them for assistance. 

    • Tanny's avatar
      Tanny
      Explorer | Level 3

      Hola,

      Yo engo el mismo problema, pero creo estar usando la versión más reciente de la api java de dropbox:

       

      El código que estoy usando es:

      package dropbox;
      
      // Include the Dropbox SDK.
      import com.dropbox.core.*;
      import com.fasterxml.jackson.core.*;
      import java.io.*;
      import java.util.Locale;
      
          
      public class Main {
      
          public static void main(String[] args) throws IOException, DbxException{
              
              // 1) Provide app key and secret to the new DbxWebAuthNoRedirect object.
              final String APP_KEY = "asdf";
              final String APP_SECRET = "asdf";
              
              DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
              
              DbxRequestConfig config = new DbxRequestConfig(
                  "JavaTutorial/1.0", Locale.getDefault().toString());
              
              DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);
              
              // 2) start the OAuth flow
              String authorizeUrl = webAuth.start();
              // Have the user sign in and authorize your app.
              System.out.println("1. Go to: " + authorizeUrl);
              System.out.println("2. Click \"Allow\" (you might have to log in first)");
              System.out.println("3. Copy the authorization code.");
              String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();        
              
              DbxAuthFinish authFinish = webAuth.finish(code);
              String accessToken = authFinish.accessToken;
      
              DbxClient client = new DbxClient(config, accessToken);
              System.out.println("Linked account: " + client.getAccountInfo().email);        
              
          }
      }

       

      Y obtengo el siguiente error:

      Exception in thread "main" com.dropbox.core.DbxException$BadResponse: unexpected response code: 400
      	at com.dropbox.core.DbxClient$4.handle(DbxClient.java:350)
      	at com.dropbox.core.DbxClient$4.handle(DbxClient.java:346)
      	at com.dropbox.core.DbxRequestUtil.doGet(DbxRequestUtil.java:242)
      	at com.dropbox.core.DbxClient.doGet(DbxClient.java:2167)
      	at com.dropbox.core.DbxClient.getAccountInfo(DbxClient.java:346)
      	at dropbox.Main.main(Main.java:49)
      C:\Users\tnogales\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
      BUILD FAILED (total time: 2 seconds)

       

       

      Me estoy rompiendo la cabeza y no encuentro la solución :(

       
       
       
       
       
      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Tanny

        De acuerdo con su captura de pantalla, también está usando una versión anterior del SDK (1.8.2). Actualice a la última versión (actualmente 3.0.8).

         

        Como referencia, el reemplazo de getAccountInfo es getCurrentAccount.
        ---

        Disculpe nuestras traducciones Nuestras traducciones fueron creadas usando un traductor en línea. Nos gustaría apoyar todos los idiomas, pero actualmente no estamos equipados para hacerlo. Aquí está la versión en inglés:

        ---

        Please excuse our translations. Our translations were created using an online translator. We'd like to support every language, but we're not currently equipped to do so. Here is the English version:

        ---

        According to your screenshot, you are also using an old version of the SDK (1.8.2). Please update to the latest version (currently 3.0.8).

         

        For reference, the replacement for getAccountInfo is getCurrentAccount.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 10 hours ago
325 Following

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 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!