cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 here!

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox Chooser response linktype for folders

Dropbox Chooser response linktype for folders

Helpful | Level 5

I am trying to get the path of the folder selected. This is how my response object looks like:

    linkType: "direct",  
    multiselect: false,  
    extensions: [],
    folderselect: true,  
    sizeLimit: 1024,

Now when I get a response path looks like 

https://www.dropbox.com/sh/bzqdza1ju95ewql5fw/AADE_uZdasdWh6N3ews4MvucNNnqZxlka?dl=0

I need to get the path like "home/test" so I can save it using.

 

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header "Authorization: Bearer " \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/Homework/math\",\"recursive\": false,\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false,\"include_mounted_folders\": true,\"include_non_downloadable_files\": true}"
PARAMETERS
{
    "path": "/Homework/math",
    "recursive": false,
    "include_media_info": false,
    "include_deleted": false,
    "include_has_explicit_shared_members": false,
   "include_mounted_folders": true,
    "include_non_downloadable_files": true
}

Any Idea how I can get the path(for folder location) from the Chooser?

3 Replies 3

Re: Dropbox Chooser response linktype for folders

Dropboxer

The Dropbox Chooser doesn't return the path like this, but it does return the "id". You can use the id value in the "path" parameter of /2/files/list_folder.

If you do want the path for some reason though, you can call /2/sharing/get_shared_link_metadata first with the "link" value returned by the Chooser as the "url" parameter.

Either way, note this will only work if you are using an access token for the same account as the one that was logged in to the Chooser.

Re: Dropbox Chooser response linktype for folders

Helpful | Level 5

Hi Greg,

Thank you for the reply.

/2/sharing/get_shared_link_metadata does work for the shared folders.

Now we have a problem with not shared ones. For not shared ones, we get name of the folder back but not the whole path. name is valid but pathlower is null. Can we get a metadata for not shared folders? We tried below 2, but it did not work.

https://api.dropboxapi.com/2/sharing/get_folder_metadata
https://api.dropboxapi.com/2/sharing/get_file_metadata

Above to gives access error. As I type this question, I noticed it might me because of "sharing", so I tried /http/documentation#files-get_metadata .

Oddly though, this gives back error for selected file/folder

Capture.PNG

Any thoughts?

Re: Dropbox Chooser response linktype for folders

Dropboxer

When you use the Chooser with the linkType: "preview" option, you'll always get back a shared link back in the "link" field, which can be used with /2/sharing/get_shared_link_metadata, whether or not the folder was previously shared. 

Note that this doesn't work with the linkType: "direct" option, since that doesn't result in actual shared links. I notice that the options you indicated originally do have linkType: "direct", but I expect that was just a typo, since it's not possible to use the linkType: "preview" option with the folderselect: true option anyway.

Anyway, the /2/sharing/get_folder_metadata and /2/sharing/get_file_metadata endpoints are meant for different kinds of sharing (shared folders and shared files, respectively, not shared links), so they won't work with the shared links returned by the Chooser.

The /2/sharing/get_shared_link_metadata endpoint will only return the path_lower value if you are using an access token for the same account as the one that was used to select the folder in the Chooser. It sounds like that wasn't the case in some of your attempts, so the field wasn't populated.

Likewise, if you specify the file path or ID for a file from a different account when calling /2/files/get_metadata, it won't be found.

Polls
Are you starting new work habits this year?

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?