I have incorporated the Dropbox API V2, with permission of "App Folder".
The call using curl succed:
curl -X POST https://api.dropboxapi.com/2/files/list_folder \
--header 'Authorization: Bearer vSBSoEs...............' \
--header 'Content-Type: application/json' \
--data '{"path":""}'
However, calling using the latest swift api fail with:
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}
I have followed the steps to incorporate the API, and use this to call the client:
func authDropbox() -> DropboxClient {
let client = DropboxClient(accessToken: DROPBOX_TOKEN)
return client
}
enum DropBoxListResult {
case Files(Array<Files.Metadata>)
case Error(String)
}
enum DropBoxResult {
case Result(Files.FileMetadata)
case Error(Error)
case PathError
}
func listDropbox(name:String, result: @escaping ((DropBoxListResult) -> Void))
{
Log.info("List:", name)
let client = authDropbox()
client.files.listFolder(path: name).response { response, error in
if let r = response {
Log.info(response)
result(DropBoxListResult.Files(r.entries))
} else if let error = error {
Log.error(error)
result(DropBoxListResult.Error(String(describing: error)))
}
}
}