cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you new to Dropbox? Our Newcomers group is the perfect place to learn the basics, find out more 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: 

Error in call to API function "files/download"

Error in call to API function "files/download"

nguyenthanhliem
New member | Level 2
Go to solution

I use DropBox API to implement Dropbox in Xamarin.Forms (NET Standard). I upload a file success, but when I download I get this error

Dropbox.Api.BadInputException: Error in call to API function "files/download": Bad HTTP "Content-Type" header: "application/x-www-form-urlencoded". Expecting one of "text/plain", "text/plain; charset=utf-8", "application/octet-stream", "application/octet-stream; charset=utf-8".

using (var client = new DropboxClient(this.AccessToken)) { using (var response = await client.Files.DownloadAsync(file.FilePath + "/" + file)) { var pickedFile = await response.GetContentAsByteArrayAsync(); //FileImagePreview.Source = ImageSource.FromStream(() => pickedFile); } }

1 Accepted Solution

Accepted Solutions

mostafa90
New member | Level 2
Go to solution

this answer solved my problem.

https://github.com/dropbox/dropbox-sdk-dotnet/issues/77#issuecomment-487972169 

 

Thanks!
In addition, I think the problem originates from Xamarin using the "AndroidClientHandler" as HttpMessageHandler. So using the current lib version, a workaround would be explicitly setting the (less efficient) HttpClientHandler
dbx = new DropboxClient(accessToken, new DropboxClientConfig() { HttpClient = new HttpClient(new HttpClientHandler()) });

 

View solution in original post

6 Replies 6

DiwakarK
Explorer | Level 4
Go to solution

I am facing error when downloading shared file using DropBox API. getting 503.

Greg-DB
Dropbox Staff
Go to solution

@nguyenthanhliem The Dropbox .NET SDK isn't officially supported on Xamarin, but there was another thread where a developer ran into this issue and was reportedly able to resolve it here:

https://www.dropboxforum.com/t5/API-Support-Feedback/Content-Type-setting-for-downloading-using-drop... 

Greg-DB
Dropbox Staff
Go to solution

@DiwakarK It sounds like you're experiencing a different issue than the one reported in this thread. Please open a new thread with the details of the issue, such as the code to reproduce it and the full error/output, so we can look into it:

https://www.dropboxforum.com/t5/forums/postpage/board-id/101000014 

nguyenthanhliem
New member | Level 2
Go to solution

I have look in your link and I think they still not found solution for this!

Greg-DB
Dropbox Staff
Go to solution

@nguyenthanhliem I was referring to this comment in particular:


@Anoop_Brijmohun wrote:

Found the solution here

https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=windows


 I'm afraid I can't offer more information though, as the Dropbox .NET SDK isn't officially supported on Xamarin. Apologies I can't be of more help in that regard!

mostafa90
New member | Level 2
Go to solution

this answer solved my problem.

https://github.com/dropbox/dropbox-sdk-dotnet/issues/77#issuecomment-487972169 

 

Thanks!
In addition, I think the problem originates from Xamarin using the "AndroidClientHandler" as HttpMessageHandler. So using the current lib version, a workaround would be explicitly setting the (less efficient) HttpClientHandler
dbx = new DropboxClient(accessToken, new DropboxClientConfig() { HttpClient = new HttpClient(new HttpClientHandler()) });

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    mostafa90 New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    nguyenthanhliem New member | Level 2
What do Dropbox user levels mean?