We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
DWade3
6 years agoExplorer | Level 3
405 method not allowed
I built file uploading application on c# using dropbox client, installed multiple devices and all working properly except one. That one's error was:
System.Net.Http.HttpRequestException: An error ...
DWade3
6 years agoExplorer | Level 3
The library is Dropbox.API (Official Dropbox .Net v2 SDK, Runtime version: v4.0.30319).
Init code:
var httpClient = new HttpClient(new WebRequestHandler { ReadWriteTimeout = 10 * 1000 })
{
Timeout = TimeSpan.FromMinutes(120)
};
try
{
var config = new DropboxClientConfig("Smart Kontor")
{
HttpClient = httpClient
};
client = new DropboxClient(strAccessToken, config);
}
catch (HttpException ex)
{
MessageBox.Show("Exception reported from RPC layer");
MessageBox.Show(" Status code: " + ex.StatusCode);
MessageBox.Show(" Message : " + ex.Message);
}Uploading code:
try
{
var fileContent = File.ReadAllBytes(source_filepath);
using (var stream = new MemoryStream(fileContent))
{
file_size = (double)stream.Length;
int numChunks = (int)Math.Ceiling(file_size / chunkSize);
progressBarControl1.Properties.Maximum = numChunks;
byte[] buffer = new byte[chunkSize];
string sessionId = null;
for (var idx = 0; idx < numChunks; idx++)
{
var byteRead = stream.Read(buffer, 0, chunkSize);
using (MemoryStream memStream = new MemoryStream(buffer, 0, byteRead))
{
if (idx == 0)
{
var result = await client.Files.UploadSessionStartAsync(body: memStream);
sessionId = result.SessionId;
}
else
{
UploadSessionCursor cursor = new UploadSessionCursor(sessionId, (ulong)(chunkSize * idx));
if (idx == numChunks - 1)
{
await client.Files.UploadSessionFinishAsync(cursor, new CommitInfo(folder + "/" + fileName), memStream);
}
else
{
await client.Files.UploadSessionAppendV2Async(cursor, body: memStream);
}
}
}
progressBarControl1.PerformStep();
}
}
Greg-DB
Dropbox Community Moderator
6 years agoYou seem to be setting some long timeout values, but other than that there doesn't seem to be anything unusual here.
Also, you didn't mention which version number of the Dropbox SDK itself you have, but I recommend upgrading to the latest version (currently v5.5.0), if you aren't already using that.
Anyway, since there's nothing clearly wrong here, and since you mentioned this only happens on one device, it seems like there's something about that device in particular that is interfering. Is there anything on that device's network connection, such as a proxy, firewall, etc. that may be interfering with the connection?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!