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: 

Re: SwiftyDropbox API Error

SwiftyDropbox API Error

H. Reo
New member | Level 1

Hello!

I'm trying out SwiftyDropbox

=> https://blogs.dropbox.com/developers/2015/05/try-out-swiftydropbox-the-new-swift-sdk-for-dropbox-api...

 

I can get user's name (with usersGetCurrentAccount() )

 

but I can't get user's filesList(with filesListFolder(path: ""))

error message is 'Bad Input: Error in call to API function "files/list_folder": request body: could not decode input as JSON'

 

 environment

Xcode7

Swift2.0

SwiftyDropbox branch 'swift-2.0'  

 

18 Replies 18

Michael K.57
New member | Level 1

UPDATE:

I applied the fix that was suggested in "#48" by Leshkoapps and it solved the problem. I'm not sure why the version that I installed via cocoapods didn't include this change, but I'm a bit of a noob to cocoapods and programming in general, so it was likely a user mistake, but in case someone else makes the same one...

 

Hi,

I'm getting this error as well, using nothing more than the sample code in the tutorial to get up and running. It does seem to be writing and reading the "hello.txt" file, but I get this:

*** Get current account ***

[request-id 2d1753ef779bb8bb8631124239e00f4e] Bad Input: Error in call to API function "users/get_current_account": request body: could not decode input as JSON

*** List folder ***

[request-id 4a7934fec1ed93d70f3f049913ee9280] Bad Input: Error in call to API function "files/list_folder": request body: could not decode input as JSON

*** Upload file ****

Uploaded file name: hello.txt

Uploaded file revision: 242d57873

*** Get file metadata ***

[request-id 82d1fb27eee8bccceb2f749b46b614b0] Bad Input: Error in call to API function "files/get_metadata": request body: could not decode input as JSON

*** Download file ***

Downloaded file name: hello.txt

Downloaded file url: file:///var/mobile/Containers/Data/Application/68429947-9A4F-4C67-89A0-EE5CCBB02BC7/Documents/C1E5D3F0-2A11-499D-A98D-9F3EACCE69FA-download.txt

Downloaded file data: Optional(<48656c6c 6f21>)

 

 

Greg-DB
Dropbox Staff

Hi Michael, that's a known issue in version 2.0.3. Please use version 2.0.2 for now. You can find more information in this thread: https://www.dropboxforum.com/hc/en-us/community/posts/203941303-Swifty-SDK-Search-API-Error-on-v2-0-...

Michael K.57
New member | Level 1

1: Wow, that's one of the fastest responses I've ever rec'd... to anything!!

2: Thank you.

3: FWIW, all I had to do to fix it and clear the errors was to change line 177 in Client.swift from :

- let request = client.manager.request(.POST, url, parameters: [:], headers: headers, encoding: ParameterEncoding.Custom {(convertible, _) in

 

to:  (Note "parameters"...)

 

- let request = client.manager.request(.POST, url, parameters: [":"], headers: headers, encoding: ParameterEncoding.Custom {(convertible, _) in

 

 After making that tiny little change, all is well!

 

 

   

 

Liang M.
New member | Level 1

Thanks Michael K..

Your tiny little change really works like a charm.

Greg-DB
Dropbox Staff

For reference, that issue was fixed in release 3.0.0.

Liang M.
New member | Level 1

Thanks Gregory.

 

But I tested the demo app "Photo Watch" a few hours ago, and it does not include the fix using the following Podfile:

 

platform :ios, '8.0'

use_frameworks!

target 'PhotoWatch' do

  pod 'SwiftyDropbox'

end

 

I am not familiar with CocoPods, and I presumed that "pod 'SwiftyDropbox'" refers to the master branch. But the pod installed still has the same issue, while the master has it fixed.

Greg-DB
Dropbox Staff

The PhotoWatch sample app currently only has SwiftyDropbox 2.0.3 installed. You'd need to do a pod update to get the latest release with the fix. 

Liang M.
New member | Level 1

Just tested it again.

pod 'SwiftyDropbox' will install SwiftyDropbox 2.0.3, which has the bug, while pod 'SwiftyDropbox', '~> 3.0.0' will install SwiftyDropbox 3.0.0.

Leah C.1
New member | Level 1

Quick update - the PhotoWatch sample app has been updated to SwiftyDropbox 3.0.0 so this issue should be fixed now. Thanks for reporting the issue!

Need more support?