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: 

API. Document preview URL error.

API. Document preview URL error.

VictorNemiro
Explorer | Level 4

Hello. Could You help me please. I created the trial dropbox team account and added some members into it.I created the new folder in private folder of the member1 and share this folder for the member2. Then i added new documaent to the created folder. How i can get Preview URL of the added document. I was trying to use the client.Sharing.GetFileMetadataAsync method but i got the 'access_error/invalid_file/...' error. 

For team folders all work fine.

Code example:

var teamClient = new DropboxTeamClient("access_token");
var adminInfo = await teamClient.Team.TokenGetAuthenticatedAdminAsync();
var allNamespaces = await teamClient.Team.NamespacesListAsync();
var sharedFolderNamespace = allNamespaces.Namespaces.SingleOrDefault(x => x.Name == "3333333333");
var adminClient = teamClient.AsAdmin(adminInfo.AdminProfile.TeamMemberId);
var folderContent = await adminClient.Files.ListFolderAsync($"ns:{sharedFolderNamespace.NamespaceId}");
var document = folderContent.Entries.SingleOrDefault(e => e.Name == "6.docx");

try
{
   var sharedData = await adminClient.Sharing.GetFileMetadataAsync($"{document.AsFile.Id}");
}
catch(Exception e)
{
   Console.WriteLine(e);
}

 

The folder is shared between 2 members.


Screenshot_2.png

1 Reply 1

Re: API. Document preview URL error.

Greg-DB
Dropboxer

The /2/sharing/get_file_metadata endpoint (which is what the GetFileMetadataAsync method uses) only supports the "Team Admin" Dropbox-API-Select-Admin mode, meaning it "can access content of team folders but not team member's private files". 

That being the case, you'll need to use the "Dropbox-API-Select-User" header instead of the "Dropbox-API-Select-Admin" header to make that call.

To do so, you should use teamClient.AsMember instead of teamClient.AsAdmin, and supply the member ID for one of the shared folder members, and use the resulting user client to make that GetFileMetadataAsync call.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?