cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

How do I set up HttpContent for my HttpClient PostAsync for dropbox api

How do I set up HttpContent for my HttpClient PostAsync for dropbox api

le h.
New member | Level 1

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", oauthToken);

HttpResponseMessage response = await client.PostAsync(link,/*what is it???*/);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return await response.Content.ReadAsStringAsync();

3 Replies 3

Re: How do I set up HttpContent for my HttpClient PostAsync for dropbox api

Greg-DB
Dropboxer

It looks like you'e trying to call the API HTTPS endpoints directly using a third party HTTP client. As we didn't make the client, we can't help with it specifically, but we can try to offer some guidance on how to use the API.

For reference, the documentation for PostAsync indicates that the second parameter is:

content
    Type: System.Net.Http.HttpContent
    The HTTP request content sent to the server.

So, it looks like you need to construct and supply a HttpContent there. You didn't mention which API or endpoint you're trying to use, so you should refer to the relevant API documentation for the endpoint you're trying to see what the right values to send up are for your case.

Re: How do I set up HttpContent for my HttpClient PostAsync for dropbox api

le h.
New member | Level 1

Dropbox api require use "POST" method. so I use postAsync(). But httpConntent of dropbox for what? 

Ex: I want to get all information of account( i have a accesstoken)

link:https://api.dropboxapi.com/2/users/get_account?access_token=my token

The HTTP request content sent to the server.


Re: How do I set up HttpContent for my HttpClient PostAsync for dropbox api

Greg-DB
Dropboxer

I'm not sure I understand your question. Can you clarify? Thanks in advance! 

Also, again (per your previous thread) note that you can't use an "access_token" URL parameter to pass up your access token to API v2. You can only use an "Authorization" header or an "authorization" URL parameter.

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    le h. New member | Level 1
What do Dropbox user levels mean?
Need more support?