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: Error Listing Contents of a folder

Error Listing Contents of a folder

dungun
Explorer | Level 3
Go to solution

Hi , I am making an api call to 

https://api.dropboxapi.com/2/files/list_folder to list the contents of a folder named "images" .  
 
here is my code 
 
$res = $client->request('POST', 'https://api.dropboxapi.com/2/files/list_folder', [
'headers'=>[
'Authorization'=> 'Bearer '.$access_token,
"Content-Type"=> "application/json"
],
'json' => [
"path"=>"/images",
"recursive"=> false,
"include_media_info"=> false,
"include_deleted"=> false,
"include_has_explicit_shared_members"=> false,
"include_mounted_folders"=> true
]
]);
 
I've tried giving and removing forward slash in path like "/images"  which gives me path not found error and other "images" which gives me " did not match pattern '(/(.|[\r\n])*)?  " error . What's wrong in my code ?
 
 
 
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
The leading slash is required when identifying non-root paths, so "/images" would be the correct format.

The not_found error indicates that there is nothing at the specified path in the connected account. That being the case, make sure that:
- you're using an access token for the account you mean to interact with.
- you're using the right path and that there is something at that path in that account. (You can use dropbox.com to check.)
- if you're using an app with the "app folder" permission, that the path exists inside the special app folder for the app in the connected account. (Apps with the "app folder" permission only have access to the app folder automatically created for them, so paths are automatically interpreted relative to that app folder. For example, "/images" would actually point to /Apps/<app folder name>/images" by default.)

View solution in original post

5 Replies 5

Greg-DB
Dropbox Staff
Go to solution
The leading slash is required when identifying non-root paths, so "/images" would be the correct format.

The not_found error indicates that there is nothing at the specified path in the connected account. That being the case, make sure that:
- you're using an access token for the account you mean to interact with.
- you're using the right path and that there is something at that path in that account. (You can use dropbox.com to check.)
- if you're using an app with the "app folder" permission, that the path exists inside the special app folder for the app in the connected account. (Apps with the "app folder" permission only have access to the app folder automatically created for them, so paths are automatically interpreted relative to that app folder. For example, "/images" would actually point to /Apps/<app folder name>/images" by default.)

dungun
Explorer | Level 3
Go to solution

Here is How root folder looks like 

dropbox1.png

 

and images folder looks like this dropbox2.png

 

 

 

 

 

and here is my php  code 

 

<?php

require 'curl/autoload.php';
use GuzzleHttp\Client;

if(isset($_GET['code'])) {
$auth_code = $_GET['code'];
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.dropboxapi.com/oauth2/token', [
    'form_params' => [
        'code' => $auth_code,
        'grant_type' => 'authorization_code',
        'client_id'=>'0r9hh54ybs8xxxx',
        'client_secret'=>'5i3rlsio4zvxxxx',
        'redirect_uri'=>'http://localhost/dbru/db_auth.php'
    ]
]);

$cont = $res->getBody()->getContents();
$access_token=json_decode($cont,true);
$access_token = $access_token['access_token'];
$res = $client->request('POST', 'https://api.dropboxapi.com/2/files/list_folder', [
    'headers'=>[
        'Authorization'=> 'Bearer '.$access_token,
        "Content-Type"=> "application/json"
    ],
    'json' => [
        "path"=>"/images",
        "recursive"=> false,
        "include_media_info"=> false,
        "include_deleted"=> false,
        "include_has_explicit_shared_members"=> false,
        "include_mounted_folders"=> true
        ]
]);

$cont = $res->getBody()->getContents();
echo '<pre>',print_r($cont);

}

?>

and it's giving me following error 

 

POST https://api.dropboxapi.com/2/files/list_folder` resulted in a `409 Conflict` response: {"error_summary": "path/not_found/..", "error": {".tag": "path", "path": {".tag": "not_found"

 

 

dungun
Explorer | Level 3
Go to solution
ok... i got this . I created a folder named images under Apps/<my App name>/images and it's giving me result . But I want to know how can I access root folder files of my users or it's not possible ?

dungun
Explorer | Level 3
Go to solution
If I want to access the folder "images" in my root folder by giving the path as 'images' or 'images/' , it gives me the following pattern matching error

POST https://api.dropboxapi.com/2/files/list_folder` resulted in a `400 Bad Request` response: Error in call to API function "files/list_folder": request body: path: 'images/' did not match pattern '(/(.|[\r\n])*)?|

I just want to list the content of my 'images' folder which is in root folder and not in Apps/<App name >/images

dungun
Explorer | Level 3
Go to solution
I fixed it by permission type 'Full Dropbox' and now it's giving all files info in dropbox root folder . Thanks man
Need more support?