0

I'm uploading file using Dropbox core API. I have written the upload code like-

RequestResult strReq = OAuthUtility.Put
                            (
                            "https://api-content.dropbox.com/1/files_put/auto/",
                            new HttpParameterCollection
                        {
                            {"access_token", "Token"},
                            {"path","/file.txt"},
                            {"overwrite", "false"}, 
                            {"autorename","false"}, 
                            {stream}
                        }
                            );

Suppose there is a existing file in root folder named file.txt and I'm again trying to upload the same name file to same folder.I have written overwrite= false and autorename=false but surprisingly there is no error status code returning in the response.Always returning the success code 200 in the response.I need to show the proper error code.

1

1 Answer 1

1

Two things stand out:

  1. Your URL is https://api-content.dropbox.com/1/files_put/auto/, but it should be (for this example) https://api-content.dropbox.com/1/files_put/auto/file.txt. The path parameter should be removed from the HttpParameterCollection.
  2. I'm unfamiliar with the library you're using, but are you sure that those parameters are turned into query parameters and that stream becomes the HTTP body? I.e. the resulting URL should be https://api-content.dropbox.com/1/files_put/auto/file.txt?overwrite=false&autorename=false&access_token=<TOKEN>, and then the file content should go in the body of the request. Please make sure this is what's happening.

Please also share the body that comes back with the 200 response. It should tell you, for example, the path of the file that got written.

Note that if you upload the exact same file content to the same path, it doesn't count as a conflict, so when looking for a 409, make sure you're uploading different content to the file.

1
  • Your last sentence solved my problem. I was trying to upload same file repeatedly in the same path.Many many thanks to you... @smarx Commented May 27, 2016 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.