You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Kuki
6 years agoExplorer | Level 4
Unable to fecth files and folders from Team folders
I am using the Dropbox Business API and trying to fetch Folders and Files present into my team folder (If you will see I have created a "General Information" folder) (The folder which is out side of ...
- 6 years ago
The exact number of entries you get back per /2/files/list_folder[/continue] page is not guaranteed. Sometimes the API may return more entries per page, and sometimes it may return fewer.
Regardless of how many entries were returned, your app needs to always check the 'has_more' value and call back for more entries if it's 'true'.
Kuki
Explorer | Level 4
Thank You for your reply: Please see my code and process I followed below:
1. STEP1: First I tried to find the the namespace ID's of the folder I have creared. I got the following output when I executed the API:
https://api.dropboxapi.com/2/team/namespaces/list
[namespaces] => Array
(
[0] => Array
(
[name] => Your team's shared workspace
[namespace_id] => 6131728736
[namespace_type] => Array
(
[.tag] => team_folder
)
)
[1] => Array
(
[name] => Sales
[namespace_id] => 6131729056
[namespace_type] => Array
(
[.tag] => shared_folder
)
)
[2] => Array
(
[name] => Custom_team_folder
[namespace_id] => 6512687312
[namespace_type] => Array
(
[.tag] => shared_folder
)
)
-----------------------------------------------------------------------------------------------
2. STEP2: Then I call this API https://api.dropboxapi.com/2/files/list_folder and passed the Namespace Id "6512687312" into my code, to get the list of files and folder present into the "Custom_team_folder" .
But I got this error:
"Operation completed without any errorsError in call to API function "files/list_folder":
This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team. Since your API app key has team member file access permissions, you can operate on a team member's Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user."
Could I know How can I solve this error, why I am getting this error
This is My code: I used CURL using PHP:
<?php
$data = array("path"=>'');
$payload = json_encode($data);
$ch = curl_init('https://api.dropboxapi.com/2/files/list_folder');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$payload);
$headers = array(
'Content-type: application/json',
'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id": "6512687312"}',
'Authorization: Bearer <REDACTED>',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
$result_file_names = curl_exec($ch);
echo 'Operation completed without any errors';
}
print_r($result_file_names);
curl_close($ch);
exit;
?>
Please see the screen shot for more reference:
----------------------------------------------------------------------------------------------------
I hope I will get the solution now.
Greg-DB
6 years agoDropbox Staff
Thanks for the additional information. Please note that you should never share your access token like this. I've redacted it from your post, but you should revoke the token since you shared it publicly.
Anyway, you're getting this error because you're using an access token for an entire Business team to call a user-specific endpoint. You can do so, but you'll need to specify which team member to operate on. You can find information on how to do so under the "Member file access" section here:
https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access
- Kuki6 years agoExplorer | Level 4
Sure, I will rember it..
Now lets come to query: with reference to what you suggested above, the folder "Custom_team_folder" is not inside any team member , it is outside of all team member folder, Please see the attached Image.. So How can I specify which team member this folder present in.
- Greg-DB6 years agoDropbox Staff
Your screenshot is showing your "team space", so to access it via the API you should set the 'Dropbox-API-Path-Root' header accordingly.
For example, to set the root to your team space itself, under which you can access the "Custom_team_folder" folder, you would set the root and path like this:
curl -X POST https://api.dropboxapi.com/2/files/list_folder \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Dropbox-API-Select-User: <MEMBER_ID>" \ --header "Content-Type: application/json" \ --header 'Dropbox-API-Path-Root: {".tag": "root", "root": "6131728736"}' \ --data "{\"path\": \"/Custom_team_folder\"}"
Or, to set the root to the "Custom_team_folder" shared folder namespace directly, you could call like this:
curl -X POST https://api.dropboxapi.com/2/files/list_folder \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Dropbox-API-Select-User: <MEMBER_ID>" \ --header "Content-Type: application/json" \ --header 'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id": "6512687312"}' \ --data "{\"path\": \"\"}"
I recommend reviewing the Namespace Guide as it goes over these options in more detail.
- Kuki6 years agoExplorer | Level 4
Hello Again,
I tried the solution you suggested , but it is not working fully.
[3] => Array
(
[.tag] => folder
[name] => General Information
[path_lower] => /general information
[path_display] => /General Information
[parent_shared_folder_id] => 6131728736
[id] => id:z3mu7FjeX1AAAAAAAAAAAQ
[shared_folder_id] => 6498180480
[sharing_info] => Array
(
[read_only] =>
[parent_shared_folder_id] => 6131728736
[shared_folder_id] => 6498180480
[traverse_only] =>
[no_access] =>
))
There is some issue,
I have created a "General Information" (6498180480 ) folder at team space,
Then I created a Folder "New_folder_123" inside it, and I shared this folder to one of my member.
I uploaded some file inside this folder, But when I am trying to retrive the files i uploaded into shared folder, showing nothing, While the files which is inside of ("Romi") folder parallel to the shared folder is coming into the list
Could you suggest me the reason<?php
$data = array("path"=>"", "recursive"=> true);
$payload = json_encode($data);$ch = curl_init('https://api.dropboxapi.com/2/files/list_folder');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$payload);$headers = array(
'Dropbox-API-Select-User:<MEMBER_ID>',
'Content-type: application/json',
'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id": "6498180480"}',
'Authorization: Bearer <REDACTED>',
);curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
$result_file_names = curl_exec($ch);
echo 'Operation completed without any errors';
}
$array_result_file_names= json_decode($result_file_names,true);
print_r($array_result_file_names);
curl_close($ch);
exit;?>
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!