cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why Delete Method is not working according to Doc?

Why Delete Method is not working according to Doc?

Irtiza_Khan
Explorer | Level 4
Go to solution

Hi, I am trying delete according to instruction from DropBox

 client?.files.deleteV2(path: "/test/path/in/Dropbox/account").response { response, error in
            if let response = response {
                print(response)
            } else if let error = error {
                switch error as CallError {
                case .routeError(let boxed, let requestId):
                    print("RouteError[\(requestId)]:")
                    
                    switch boxed.unboxed as Files.DeleteError {
                    case .pathLookup(let lookupError):
                        switch lookupError {
                        case .notFound:
                            print("There is nothing at the given path.")
                        case .notFile:
                            print("We were expecting a file, but the given path refers to something that isn't a file.")
                        case .notFolder:
                            print("We were expecting a folder, but the given path refers to something that isn't a folder.")
                        case .restrictedContent:
                            print("The file cannot be transferred because the content is restricted...")
                        case .malformedPath(let malformedPath):
                            print("Malformed path: \(malformedPath)")
                        case .other:
                            print("Unknown")
                        }
                    case .pathWrite(let writeError):
                        print("WriteError: \(writeError)")
                    // you can handle each `WriteError` case like the `DeleteError` cases above
                    case .other:
                        print("Unknown")
                    }
                case .internalServerError(let code, let message, let requestId): break
                }
            }
        } // End Of client?
        
        DropboxClientsManager.authorizedClient?.files.deleteV2(path: "/test/path/in/Dropbox/account").response { response, error in
            if let response = response {
                print(response)
            } else if let error = error {
                switch error as CallError {
                case .routeError(let boxed, let requestId):
                    print("RouteError[\(requestId)]:")
                    
                    switch boxed.unboxed as Files.DeleteError {
                    case .pathLookup(let lookupError):
                        switch lookupError {
                        case .notFound:
                            print("There is nothing at the given path.")
                        case .notFile:
                            print("We were expecting a file, but the given path refers to something that isn't a file.")
                        case .notFolder:
                            print("We were expecting a folder, but the given path refers to something that isn't a folder.")
                        case .restrictedContent:
                            print("The file cannot be transferred because the content is restricted...")
                        case .malformedPath(let malformedPath):
                            print("Malformed path: \(malformedPath)")
                        case .other:
                            print("Unknown")
                        }
                    case .pathWrite(let writeError):
                        print("WriteError: \(writeError)")
                    // you can handle each `WriteError` case like the `DeleteError` cases above
                    case .other:
                        print("Unknown")
                    }
                case .internalServerError(let code, let message, let requestId): break
                }
            }
        } // End Of DropboxClientsManager.authorizedClient?

But Showing Error message " Tuple pattern has the wrong length for tuple type '(Box<(Files.DeleteError)>, String?, String?, String?)' (aka '(Box<Files.DeleteError>, Optional<String>, Optional<String>, Optional<String>)')"


Also I have a Question.

***What is the differrence between client? and 

DropboxClientsManager.authorizedClient?


N.B. I am using Xcode 8.3.1 and swift 3

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Apologies for the trouble, it looks like the SwiftyDropbox readme is a little out of date. This line:

case .routeError(let boxed, let requestId):

should instead be:

case .routeError(let boxed, let userMessage, let errorSummary, let requestId):

I'll ask the team to update that in the documentation.

 

`DropboxClientsManager.authorizedClient` is a singleton you can use for convenience for storing the `DropboxClient` object. The `client` variable in the examples also just refers to a `DropboxClient` object. You can use whichever you want.

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

Apologies for the trouble, it looks like the SwiftyDropbox readme is a little out of date. This line:

case .routeError(let boxed, let requestId):

should instead be:

case .routeError(let boxed, let userMessage, let errorSummary, let requestId):

I'll ask the team to update that in the documentation.

 

`DropboxClientsManager.authorizedClient` is a singleton you can use for convenience for storing the `DropboxClient` object. The `client` variable in the examples also just refers to a `DropboxClient` object. You can use whichever you want.

Irtiza_Khan
Explorer | Level 4
Go to solution
but when i try to check
if(client != nil){
}
else{
print("Nil")
}
Then it prints NIl in console. Why?

Greg-DB
Dropbox Staff
Go to solution
The `client` variable would just be a variable like any other in your app. If the `nil` check is coming back like that, it means it is not currently set. You need to set and manage it in your code. (For that reason, `DropboxClientsManager.authorizedClient` is generally more convenient.)
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Irtiza_Khan Explorer | Level 4
What do Dropbox user levels mean?