cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: Use Dropbox API search results to generate dropbox.com file preview urls

Use Dropbox API search results to generate dropbox.com file preview urls

qwesafesa
Explorer | Level 3

We are creating application to help users find their files/folder in dropbox.

 

For searching we used dropbox API route: https://api.dropboxapi.com/2/files/search_v2

 

The goal is: based on results generate proper dropbox.com urls to let user visit dropbox site with opened file.

The issue is: results do not have namespaces in their lower_path or display_path, which leads to not-existing file locations.

 

Javascript Code (using Axios):

const response = await userClient.post(
    '/2/files/search_v2',
    {
      query,
      options: { max_results: limit },
      match_field_options: { include_highlights: true }
    },
    {
      headers: {
        'Content-Type': 'application/json'
      }
    }
  );

  const results = response.data.matches;

Correct behavior:

user is logged in our system via oauth2. User account is simple Dropbox account, and there is basic get started file, its path from API will be 

"path_display": "/Get Started with Dropbox.pdf"

It's okay to generate this link:  https://www.dropbox.com/home?preview=Get+Started+with+Dropbox.pdf

 

Incorrect behavior:

User has Dropbox Business account.

With Dropbox Business, each user has it's own namespace

And the basic Dropbox Business file "Get Started with Dropbox.pdf" url will look something like this

https://www.dropbox.com/home/Username?preview=Get+Started+with+Dropbox.pdf

 

But from the API search request, it's path will be the same 

"path_display": "/Get Started with Dropbox.pdf"

And i see no namespace_id returned in my search query.

 

So, the question is: how to search dropbox files/folders and properly determine, to which namespace they belong?

 

Thanks in advance.

 

 

1 Reply 1

Greg-DB
Dropbox Staff

Unfortunately, the Dropbox API doesn't offer an officially supported way to get or build the private Dropbox web site URL for a file or folder like this, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

 

For reference, when calling /2/files/search_v2, the paths in result will be relative to the root for the call (e.g., the user's own folder, or a team space, etc.), which can be specified via 'the 'Dropbox-API-Path-Root' header. If not specified, this is the user's own folder by default. Please refer to the Namespace Guide for more information. When applicable/present, you can also check the returned 'sharing_info' field for information about where a file/folder exists.

Need more support?