Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
ravisharma
8 years agoNew member | Level 2
Unable to list folder files in iOS Swift
I am facing below error when I am trying to list folder or get current account info. Please help
Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dropbox.com/2/users/get_current_account, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dropbox.com/2/users/get_current_account}
Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dropbox.com/2/files/list_folder, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dropbox.com/2/files/list_folder}
Below the code I have tried.
let client = DropboxClient(accessToken: "MYTOKEN")
client.users.getCurrentAccount().response { (response, error) in
if let result = response {
print(result)
} else if let error = error {
print(error)
}
}
client.files.listFolder(path: "").response(queue: DispatchQueue(label: "MyCustomSerialQueue")) { response, error in
if let result = response {
print(Thread.current) // Output: <NSThread: 0x61000007bec0>{number = 4, name = (null)}
print(Thread.main) // Output: <NSThread: 0x608000070100>{number = 1, name = (null)}
print(result)
} else if let error = error {
print(error)
}
}
1 Reply
- Greg-DB8 years ago
Dropbox Community Moderator
It looks like your client object is probably going out of scope before the request can finish. Note that the actual API calls are made asynchronously, so the client object may be gone by the time the network call finishes.
Try keeping your client around instead. For example, you can use DropboxClientsManager.authorizedClient.
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
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!