Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

9 Replies

  • MarcoLI's avatar
    MarcoLI
    New member | Level 2
    9 years ago

    Hy!

    When I try to run my code it displays the following error: 

     

    "Exception in thread "Thread-2" java.lang.NoSuchMethodError: com.dropbox.core.DbxHost.getApi()Ljava/lang/String;
    at com.dropbox.core.v2.files.DbxUserFilesRequests.delete(DbxUserFilesRequests.java:218)
    at com.dropbox.core.v2.files.DbxUserFilesRequests.delete(DbxUserFilesRequests.java:248)"

     

    My code: 

     

    public Metadata delete(String path) throws DeleteErrorException, DbxException{
    
    Metadata metadata = null;
    
    DbxRequestConfig config = new DbxRequestConfig(
    "JavaTutorial/1.0", Locale.getDefault().toString());
    
    try{
    
    //DbxHost DEFAULT = new DbxHost("api.dropboxapi.com","content.dropboxapi.com","www.dropbox.com","notify.dropboxapi.com");
    
    DbxClientV2 cli = new DbxClientV2(config, "<REDACTED>", DbxHost.Default);
    metadata = cli.files().delete(path);
    
    cli.files().delete(path);
    
    JOptionPane.showMessageDialog(null, "apagado");
    
    }catch(DbxException | HeadlessException erro){
    
    JOptionPane.showMessageDialog(null, erro);
    
    }
    
    return metadata;
    
    }

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    MarcoLI I can't seem to reproduce this error. What version of the SDK do you have installed?

     

    In any case, a few things I noticed:

     

    - You don't need to redefine the Dropbox hosts. (Though, you have it commented it out anyway.)

    - You don't need to pass in the Dropbox hosts manually. You should just use the DbxClientV2 constructor that doesn't take a DbxHost.

    - If you do pass it in explicitly, it should be DbxHost.DEFAULT, not DbxHost.Default.

    - I redacted it from your post, but you should revoke that access token since you posted it publicly.

  • wei-qiang's avatar
    wei-qiang
    New member | Level 2
    9 years ago
    hi i've got the same issue have you found a solution yet?
  • cgirecruitment1's avatar
    cgirecruitment1
    Explorer | Level 4
    7 years ago

    Hi Greg,

     

    I am not able to use the same "delete" method using Dropbox V2 API.

     

    Error:

    Unknown error occured :String 'path' does not match pattern

    I am getting this error, when i pass path as "id:somevalue" , whereas same is working from Dropbox API Explorer.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    cgirecruitment1 You should be able to use the delete method with file IDs. Can you share the actual code and path parameter value you're using that's resulting in this error? Thanks in advance! 

  • cgirecruitment1's avatar
    cgirecruitment1
    Explorer | Level 4
    7 years ago

    Yes. My code looks like this:

    public String deleteFile(String path)
    throws DbxException {

    DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("Dropbox Documents Delete").build();
    DbxClientV2 client = new DbxClientV2(requestConfig, "AccessToken");

     

    FileMetadata fileMetadata = (FileMetadata) client.files().delete(path);
    return fileMetadata.getId();
    }

     

    Path Parameter:  id:MWWBdvN6DaAAAAAAAAAAwA

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!