We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
nzmike
7 years agoExplorer | Level 3
Xamarin.DropBox.APi - HTTP 400 (Bad request) on DownloadAsync
Hi,
I have the following code in a static helper class which works perfectly in a Windows UWP app:
public static DropboxClient dbxClient { get; private set; }
......
public static async Task<string> DownloadFile(string filePath, string fileName, string accessToken)
{
string output = null;
try
{
if (dbxClient == null)
dbxClient = new DropboxClient(accessToken);
if (dbxClient != null)
{
var downloadResponse = await dbxClient.Files.DownloadAsync(filePath + fileName);
var content = await downloadResponse.GetContentAsStringAsync();
DebugInfo += $"{filePath} downloaded - revision {downloadResponse.Response.Rev}";
output = content;
}
else
throw new Exception("DownloadFile: DropBox client not authenticated");
}
catch (Exception ex)
{
Exception = ex;
output = ex.Message;
}
return output;
}
Now I want to convert the app I created in UWP to Android so I copied it into my new Xamarin.Forms app and replaced the usual Dropbox.API NuGet package with Xamarin.DropBox.Api, but when I run the code I get this message:
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".
I have googled this and searched on this forum but (so far) can't find anything relevant - can someone please let me know what I'm doing wrong? DropBoxClient seems to want a content-type (which is fair enough) but there does not seem to have any way to actually specify that from what I can see in the DropBoxClient properties and methods available.
Thanks in advance for any help offered.
The Dropbox API does require one of a certain set of Content-Type values for download calls like this. The official Dropbox.Api library (i.e., the official Dropbox API v2 .NET SDK) does automatically set a valid Content-Type, so you don't need to do that yourself when using it.
It sounds like when you switch to Xamarin and the Xamarin.Dropbox.Api library, something is overriding it and setting an incorrect Content-Type. I'm afraid we can't offer help with those though, as they're made/maintained by a third party. You may be better served contacting the Xamarin maintainers or asking on a Xamarin forum.
- Greg-DBDropbox Staff
The Dropbox API does require one of a certain set of Content-Type values for download calls like this. The official Dropbox.Api library (i.e., the official Dropbox API v2 .NET SDK) does automatically set a valid Content-Type, so you don't need to do that yourself when using it.
It sounds like when you switch to Xamarin and the Xamarin.Dropbox.Api library, something is overriding it and setting an incorrect Content-Type. I'm afraid we can't offer help with those though, as they're made/maintained by a third party. You may be better served contacting the Xamarin maintainers or asking on a Xamarin forum.
- nzmikeExplorer | Level 3
Thanks Greg - I thought the Xamarin DropBox APi was a variant on the official but as it's not I'll ask over on the Xamarin forums.
- luismiguelsiNew member | Level 2
Hello,
I have the same problem. did you solve it?.
thanks
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 6 hours agoIf 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 or Facebook.
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!