Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:07:05+00:00 2026-05-27T18:07:05+00:00

I am trying to upload a file to the Dropbox REST web service while

  • 0

I am trying to upload a file to the Dropbox REST web service while at the same time using Devdefined’s OAuth library.

This is the method I’m using:

    public static void UploadFile(string filenameIn, string directoryIn, byte[] dataIn)
    {
        DropBox.session.Request().Put().ForUrl("https://api-content.dropbox.com/1/files_put/" + directoryIn + filenameIn)
            .WithQueryParameters(new { param = dataIn });
    }

The method doesn’t appear to do anything, nor throw any exceptions. There’s no errors in the output either. I’ve tried using breakpoints to confirm it’s calling the code as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:07:05+00:00Added an answer on May 27, 2026 at 6:07 pm

    The reason you are not receiving an error is because the request is not being executed – to execute the request you need to fetch the response – there is a number of ways to do this, but often the simplest is just to fetch the text back using the method ReadBody().

    Uploading the contents of a file can not be done as a query parameter – as per the dropbox REST API, the entire body of the put request should be the file’s contents.

    Essentially for this all to work you will need to:

    • Include the root path “dropbox” or “sandbox” as per the API in your Url, which I think you are missing. You use “sandbox” if your DropBox application has been configured with an application folder.
    • Set “UseHeaderForOAuthParameters” to true in the consumer context, to ensure the OAuth signature etc. is passed as request headers, as opposed to being encoded as form parameters (because the entire body is raw data).
    • Use the “WithRawContent(byte[] contents)” method to add the file’s contents to the request.
    • Use the “ReadBody()” method at the very end of the PUT request method chain, to cause the request to be executed.

    The result will be a string containing JSON that should look something like this:

    {
      "revision": 5, 
      "rev": "5054d8c6e", 
      "thumb_exists": true, 
      "bytes": 5478,
      "modified": "Thu, 29 Dec 2011 10:42:05 +0000",
      "path": "/img_fa06e557-6736-435c-b539-c1586a589565.png", 
      "is_dir": false, 
      "icon": "page_white_picture",
      "root": "app_folder",
      "mime_type": "image/png",
      "size": "5.3KB"
    }
    

    I’ve added an example to the DevDefined.OAuth-examples project on github that demonstrates how to do GET and PUT requests with DropBox:

    https://github.com/bittercoder/DevDefined.OAuth-Examples/blob/master/src/ExampleDropBoxUpload/Program.cs

    And here’s the code specifically required for a put request:

    var consumerContext = new OAuthConsumerContext
    {
        SignatureMethod = SignatureMethod.HmacSha1,
        ConsumerKey = "key goes here",
        ConsumerSecret = "secret goes here", 
        UseHeaderForOAuthParameters = true
    };
    
    var session = new OAuthSession(consumerContext, "https://api.dropbox.com/1/oauth/request_token",
       "https://www.dropbox.com/1/oauth/authorize",
       "https://api.dropbox.com/1/oauth/access_token");
    
    IToken requestToken = session.GetRequestToken();
    
    string authorisationUrl = session.GetUserAuthorizationUrlForToken(requestToken);
    
    Console.WriteLine("Authorization Url: {0}", authorisationUrl);
    
    // ... Authorize request... and then...
    
    session.ExchangeRequestTokenForAccessToken(requestToken);
    
    string putUrl = "https://api-content.dropbox.com/1/files_put/sandbox/some-image.png";
    
    byte[] contents = File.ReadAllBytes("some-image.png");
    
    IConsumerRequest putRequest = session.Request().Put().ForUrl(putUrl).WithRawContent(contents);
    
    string putInfo = putRequest.ReadBody();
    
    Console.WriteLine("Put response: {0}", putInfo);
    

    Hopefully that should clear things up a bit, unfortunately without documentation it’s a little tricky to figure these things out by just looking at the source code 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload a file using a RESTful web service as follows:
I am trying to upload a File with one parameter using spring 3. This
I'm trying to upload file, using XMLHTTPRequest, and sending this headers: Content-Type:multipart/form-data, boundary=xxxxxxxxx --xxxxxxxxx
I'm trying to upload an edited version of a .txt file to Dropbox using
I am trying to upload a file using jQuery ajax, but keep getting this
I'm trying to upload large file (>100Mb) using Apache commons-net FTP library to Secure
I am trying to upload file using php. I am using the function move_uploaded_file.
I was trying to upload file(s) using PrototypeJs request method but I failed. The
I am trying to upload a file or stream of data to our web
I'm trying to upload a file using Watin and C#. Under Windows XP, Watin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.