cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you’ve changed your email address, now's the perfect time to update it on your Dropbox account and we’re here to help! Learn 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: 

405 method not allowed

405 method not allowed

DWade3
Explorer | Level 3

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 occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (405) Method Not Allowed...

 

Is there might be Router block? or any suggestions? How do i solve?

4 Replies 4

Greg-DB
Dropbox Staff

I'll be happy to help with any issues you're having with the Dropbox API, but I'll need some more information. Please reply with:

  • the name and version number of the platform and SDK/library you are using, if any
  • the steps to reproduce the issue, including relevant code snippet(s), but don't include the access token

DWade3
Explorer | 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();
                    }
                }

 

DWade3
Explorer | Level 3

I attached the code, please see below

Greg-DB
Dropbox Staff

You 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? 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    DWade3 Explorer | Level 3
What do Dropbox user levels mean?