Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to access "users/get_current_account" #42

Closed
Sahilberi opened this issue Dec 21, 2015 · 12 comments
Closed

unable to access "users/get_current_account" #42

Sahilberi opened this issue Dec 21, 2015 · 12 comments

Comments

@Sahilberi
Copy link

Hi,
i'm following this link https://www.dropbox.com/developers/documentation/swift#tutorial, but after authorized the client when i try to access data of user it returns nil. as it shows Bad Input: Error in call to API function "users/get_current_account": request body: could not decode input as JSON or
Bad Input: Error in call to API function "files/list_folder": request body: could not decode input as JSON.

@varenc
Copy link
Contributor

varenc commented Dec 22, 2015

hey there, could you share a little more information on how we might be able to reproduce that problem? make a link to a project you've setup that reproduces this?

@Sahilberi
Copy link
Author

hi @varenc , i just downloaded Swiftdropbox zip file and put it into my project(because of 'Swiftdropbox' not updated for 'Alamofire' 3.1 and i'm using Alamofire 3.1). i followed this link https://blogs.dropbox.com/developers/2015/05/try-out-swiftydropbox-the-new-swift-sdk-for-dropbox-api-v2/ step by step.
but when i try to access client.users.getCurrentAccount().response , it gives me nil
if let client = Dropbox.authorizedClient {

    // Get the current user's account info
    client.users.getCurrentAccount().response { response, error in
       print(response) //nil 
        print("*** Get current account ***")
        if let account = response {
            print("Hello \(account.name.givenName)!")
        } else {
            print(error!)
        }
    }

    // List folder
    client.files.listFolder(path: "").response { response, error in
        print("*** List folder ***")
        if let result = response {
            print("Folder contents:")
            for entry in result.entries {
                print(entry.name)
            }
        } else {
            print(error!)
        }
    }

@smarx
Copy link

smarx commented Dec 23, 2015

If response is nil, then error should be non-nil. Was an error printed?

@Sahilberi
Copy link
Author

yes error was printed . it shows Bad Input: Error in call to API function "users/get_current_account": request body: could not decode input as JSON.

@atomkirk
Copy link

I am having the exact same problem when trying to access files/list_folder. Do something like this and you will be able to reproduce the problem:

        if let client = Dropbox.authorizedClient {
            StatusHUD.showLoadingWithCompletion {
                client.files.listFolder(path: self.path).response { response, error in
                    StatusHUD.dismissWithCompletion {
                        if let result = response {
                            self.entries = result.entries
                            self.tableView.reloadData()
                        } else {
                            self.showAlertWithTitle("Error", description: error?.description ?? "There was an unknown error.")
                        }
                    }
                }
            }
        }

@tylermann
Copy link

I was having the same problems with the latest checkout. The issue seems to be caused by the following:
--- a/Pods/SwiftyDropbox/Source/Client.swift
+++ b/Pods/SwiftyDropbox/Source/Client.swift

-        
-        let request = client.manager.request(.POST, url, parameters: [:], headers: headers, encoding: ParameterEncoding.Custom {(convertible, _) in
+
+        let request = client.manager.request(.POST, url, parameters: ["something":"here"], headers: headers, encoding: ParameterEncoding.Custom {(convertible, _) in
                 let mutableRequest = convertible.URLRequest.copy() as! NSMutableURLRequest
                 mutableRequest.HTTPBody = dumpJSON(params)
                 return (mutableRequest, nil)

The block for the custom parameter encoding is not being run when an empty dictionary is passed in. If you add something to the parameters argument then the block is run. I'm guessing this probably used to work and broke in the recent Alamofire uprev to 3.0?

@atomkirk
Copy link

That is the code I suspected as well but wasnt sure. Sure wish theyd expose the xproj and unit tests so we could help out ;)

@varenc
Copy link
Contributor

varenc commented Dec 26, 2015

thanks for digging into this! Our office is mostly shutdown during the holidays but we should be able to get a fix out for this as soon as folks are back in the office.

The client aspect of these SDKs are actually automatically generated from a specification of the API. This lets us ensure that all our SDKs of are always 100% up to date with the API, but it does complicate the SDK. We plan to release the full code for the generators in the future, but we're not there yet.

@Sahilberi
Copy link
Author

thanks @tylermann . now it's working fine ,you were right it is happening bcz an empty dictionary is passed.

@marecektn
Copy link

voting for fix :)

@everappz
Copy link

everappz commented Jan 4, 2016

fixed in #48

@varenc
Copy link
Contributor

varenc commented Jan 6, 2016

I just accepted #46 which should fix this. (#48 fixes this too but 46 was first! 😄 )

@greg-db greg-db closed this as completed Feb 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants