cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right 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: 

Old dropbox and new dropbox API

Old dropbox and new dropbox API

Omri1984
Explorer | Level 4

Hi ,

i know that dropbox made a lot of changes in the last few years.

i want to understand something 

there where a time that i needed to check the account , and check if the account is  team in order to identify if it is a space team(new team)  or the old one.

 

is this the case for today as well. or that dropbox deprecated all there old teams of the old dropbox and we move only to work with the new one?

 

i am using the api of dropbox and i used to support the old and the new dropbox themes.

 

can someone help me to understand 🙂

 

 

attaching the response from rootinfo 

dropbox img.PNG

21 Replies 21

Здравко
Legendary | Level 20

Hi @Omri1984,

Why are you doing your life difficult and trying to rediscover hot water? 😯😀 That, what you're trying to figure out is already done in the official Dropbox .NET SDK and you can use it ready for use! 🤷 Why you don't you make your life easier? 😉

 


@Omri1984 wrote:

...

var requestBody = "{\"features\":[{\".tag\":\"\"distinct_member_home\"},{\".tag\":\"team_shared_dropbox\"}]}";

var content = new StringContent(JsonConvert.SerializeObject(requestBody), Encoding.UTF8, "application/json");

...

Result: "Error in call to API function \"users/features/get_values\": request body: expected object, got string"

 

am i missing something here 


🙂 Maybe "missing" is not the exact word. Do you understand what JSON object means? What do you have in your requestBody variable? 🤔 Is that an object or some string what you later serialize? 🧐

Actually you have done something twice, not missing! 😉 That what the error message signals for.

By the way you are setting you content type twice. The second one:


@Omri1984 wrote:

...
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

...


... may be skipped since already exists in previous code statement.

Hope this drive you in right direction.

Omri1984
Explorer | Level 4

Bu greg wrote before that some of the parameters are not support by the sdk.

i need to support in my code all the options.

in the past we used the root.info.isTeam.

 

regrading the string of request body , it is a string that i am serializing it to an object 

 

but now the root.info changed. so need to get the account value to determent what type of team / new team or personal  the user is authenticate with 

 

 

edit,

 

also I tried to remove the

content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

 

but still got the same error 

 

if you can show another way using c# also good 🙂

Здравко
Legendary | Level 20

@Omri1984 wrote:

...

regrading the string of request body , it is a string that i am serializing it to an object 

...


Yes, you definitely have no any idea what JSON means. You CANNOT serialize string to object!!! You may rather serialize object to string and that's the idea of JSON and that's what it's used for actually. Learn more about JSON - it comes from javascript, but it's the same in all languages.

An easy thing, you can do, is to remove the serialization you have already done by hands actually.

Omri1984
Explorer | Level 4

@Здравко What i meant is that i am serialize it to a json object 

This is the response after i removed the serialization 

 "Error in call to API function \"users/features/get_values\": request body: could not decode input as JSON"

Здравко
Legendary | Level 20

Hm...🤔 Did you by any chance exchange URI and content? Be more careful! 🙂

 

Take a look here how to order parameters and their format too. 😉

Omri1984
Explorer | Level 4

@Здравко  this is all i am doing 

var client = new HttpClient()
{
BaseAddress = new Uri(" https://api.dropboxapi.com"),
DefaultRequestHeaders =
{

}
};

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("UTF8"));

 


var requestBody = "{\"features\":[{\".tag\":\"\"other\"}]}";

var content = new StringContent(requestBody, Encoding.UTF8, "application/json");

var res = await httpClient.PostAsync("/2/users/features/get_values",content);

Здравко
Legendary | Level 20

@Omri1984, I don't know what you have done, but the above is definitely NOT the code you have used; it wouldn't even compile. There are errors inside - visible on first look on!

You can do something else though. Try to send request to a test site where you can see what actually you're sending (just type "test post requests" or something like in Google and select a site you prefer; not to advertise some). Once you have everything configured properly, just set the Dropbox endpoint back. Don't ask for every syntax error or similar you made. If needed pass a refresh course.

Greg-DB
Dropbox Staff

@Omri1984 The team features tell you information about the entire team itself, and the user features tell you information about the specific user account (which may be a member of a team, and so there would be some overlap with the team features). Exactly which you use is up to you, depending on what you need to know in your app.

 

In any case, like Здравко mentioned, I do not recommend trying to re-implement these calls outside of the .NET SDK. If you're using the .NET SDK, I recommend continuing to use it as-is. While it does not have the new feature values implemented natively, you can use the root information returned by GetCurrentAccountAsync (like shown in your original screenshot) to determine the same things. Please refer to my earlier message for an explanation of the conditions to check.

Omri1984
Explorer | Level 4

Hi @Greg-DB 

From the get current account i used to use in the past. It return is team = true when it was a new space team

But now it is changed.

Can please explain again how can i know if it is a bew team old team or user . And if it is a user if i can tell if it auser inside a old team new team or jist user with no team .

Please clear that for me 😁

Greg-DB
Dropbox Staff

@Omri1984 Here's a basic example of how you can use the existing root information to determine the same information as the feature values using the .NET SDK:

var accountInfo = await this.client.Users.GetCurrentAccountAsync();

bool team_shared_dropbox = accountInfo.RootInfo.IsTeam;
Console.WriteLine("team_shared_dropbox: " + team_shared_dropbox);
bool distinct_member_home = accountInfo.RootInfo.RootNamespaceId != accountInfo.RootInfo.HomeNamespaceId;
Console.WriteLine("distinct_member_home: " + distinct_member_home);
Need more support?
Who's talking

Top contributors to this post

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