Hi all,
I was sure I'd posted this question to the forums already but my profile does not show any questions having been posted so I'm trying again.
Ok, so I have an existing Winsdows10 UWP app called "PassPort" which uses v2 of the standard DropBox API to upload and download data files without issue. Now I want to get this app working on my Android phone (Nokia 8 running Android 8.1) so I created a XF project, copied my download/upload code over to the main project and added Xamarin.Dropbox API from NuGet. I can create a valid Dropbox session, get basic stuff like user details etc but when I try to download a file I get this error:
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".
Now I cannot see anywhere in the Xamarin.Dropbox API that allows me to specify a content-type for the header so I am really stuck!
Here is the code I'm using to download the file - this works perfectly every time with the standard Dropbox API.
public static async Task<string> DownloadFile(string filePath, string fileName) { string output = null; try { if (dbxClient == null) dbxClient = new DropboxClient(accessToken); if (dbxClient != null) { var downloadResponse = await dbxClient.Files.DownloadAsync(filePath + fileName); var output = await downloadResponse.GetContentAsStringAsync(); } else throw new Exception("DownloadFile: DropBox client not authenticated"); } catch (Exception ex) { Exception = ex; output = ex.Message; } return output; }
Now I'll admit this is my first Xamarin Forms project so perhaps I'm doing something wrong but the app runs perfectly Ok on the "Android_accelerated_c86_Oreo" 8.1 emulator until I try to run the above code...so does anyone know how I can resolve this?
Please don't tell me to post over on the official Dropbox forums - I did that and they replied that as it's a Xamarin specific version of the Dropbox API, I would need to ask over here on the Xamarin forums.