<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Targeting a folder at the root of a business account. in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597489#M27769</link>
    <description>&lt;P&gt;I am trying to upload files into a folder at the root of a DropBox Business account.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can list all the folders including the target folder by using the following.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;$cheaders &lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;array&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Authorization: Bearer '&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;DROPBOX_APP_TOKEN&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;'Content-Type: application/json'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;$ch &lt;/SPAN&gt;&lt;SPAN&gt;= curl_init(&lt;/SPAN&gt;&lt;SPAN&gt;'https://api.dropboxapi.com/2/team/namespaces/list'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;$payload &lt;/SPAN&gt;&lt;SPAN&gt;= json_encode( &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, &lt;/SPAN&gt;&lt;SPAN&gt;CURLOPT_RETURNTRANSFER&lt;/SPAN&gt;&lt;SPAN&gt;, true &lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;$response &lt;/SPAN&gt;&lt;SPAN&gt;= curl_exec(&lt;/SPAN&gt;&lt;SPAN&gt;$ch&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;$folders &lt;/SPAN&gt;&lt;SPAN&gt;= json_decode(&lt;/SPAN&gt;&lt;SPAN&gt;$response&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;foreach&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;$folders &lt;/SPAN&gt;&lt;SPAN&gt;as &lt;/SPAN&gt;&lt;SPAN&gt;$namespaces&lt;/SPAN&gt;&lt;SPAN&gt;){&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    var_dump(&lt;/SPAN&gt;&lt;SPAN&gt;$namespaces&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;That works and returns a listing of the namespace ID's and the human readable folder names including the one I would like to upload to at the Root level (outside of the members folders)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  object(stdClass)#8 (3) {
    ["name"]=&amp;gt;
    string(10) "RootTest"
    ["namespace_id"]=&amp;gt;
    string(11) "123456789"
    ["namespace_type"]=&amp;gt;
    object(stdClass)#9 (1) {
      [".tag"]=&amp;gt;
      string(13) "shared_folder"
    }
  }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, when I try to target this folder [123456789] using the&amp;nbsp;&lt;A title="Dropbox-API-Path-Root" href="https://www.dropbox.com/developers/reference/path-root-header-modes" target="_self" rel="noopener noreferrer"&gt;Dropbox-API-Path-Root&lt;/A&gt;&amp;nbsp;to upload files I get the following error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Error in call to API function "files/upload": 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 &amp;lt;&lt;A href="https://www.dropbox.com/developers/documentation/http/teams" target="_blank" rel="noopener noreferrer"&gt;https://www.dropbox.com/developers/documentation/http/teams&lt;/A&gt;&amp;gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$path = 'test.txt';
$fp = fopen($path, 'rb');
$size = filesize($path);

$cheaders = array('Authorization: Bearer '.DROPBOX_APP_TOKEN,
    'Content-Type: application/octet-stream',
    'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id":"123456789"}',
    'Dropbox-API-Arg: {"path":"/test.txt","mode":{".tag":"add"}}');

$ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

echo $response;
curl_close($ch);
fclose($fp);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you target a folder at the Root of the dropbox account which has the namespace id of 123456789 in this example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 May 2022 09:05:07 GMT</pubDate>
    <dc:creator>lexomatic</dc:creator>
    <dc:date>2022-05-17T09:05:07Z</dc:date>
    <item>
      <title>Targeting a folder at the root of a business account.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597489#M27769</link>
      <description>&lt;P&gt;I am trying to upload files into a folder at the root of a DropBox Business account.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can list all the folders including the target folder by using the following.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;$cheaders &lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;array&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Authorization: Bearer '&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;DROPBOX_APP_TOKEN&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;'Content-Type: application/json'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;$ch &lt;/SPAN&gt;&lt;SPAN&gt;= curl_init(&lt;/SPAN&gt;&lt;SPAN&gt;'https://api.dropboxapi.com/2/team/namespaces/list'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;$payload &lt;/SPAN&gt;&lt;SPAN&gt;= json_encode( &lt;/SPAN&gt;&lt;SPAN&gt;array&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;"limit"&lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;100 &lt;/SPAN&gt;&lt;SPAN&gt;) )&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;curl_setopt(&lt;/SPAN&gt;&lt;SPAN&gt;$ch&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;CURLOPT_POSTFIELDS&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;$payload &lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;curl_setopt(&lt;/SPAN&gt;&lt;SPAN&gt;$ch&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;CURLOPT_HTTPHEADER&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;$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&lt;SPAN&gt;$namespaces&lt;/SPAN&gt;&lt;SPAN&gt;){&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    var_dump(&lt;/SPAN&gt;&lt;SPAN&gt;$namespaces&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;That works and returns a listing of the namespace ID's and the human readable folder names including the one I would like to upload to at the Root level (outside of the members folders)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  object(stdClass)#8 (3) {
    ["name"]=&amp;gt;
    string(10) "RootTest"
    ["namespace_id"]=&amp;gt;
    string(11) "123456789"
    ["namespace_type"]=&amp;gt;
    object(stdClass)#9 (1) {
      [".tag"]=&amp;gt;
      string(13) "shared_folder"
    }
  }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, when I try to target this folder [123456789] using the&amp;nbsp;&lt;A title="Dropbox-API-Path-Root" href="https://www.dropbox.com/developers/reference/path-root-header-modes" target="_self" rel="noopener noreferrer"&gt;Dropbox-API-Path-Root&lt;/A&gt;&amp;nbsp;to upload files I get the following error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Error in call to API function "files/upload": 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 &amp;lt;&lt;A href="https://www.dropbox.com/developers/documentation/http/teams" target="_blank" rel="noopener noreferrer"&gt;https://www.dropbox.com/developers/documentation/http/teams&lt;/A&gt;&amp;gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;$path = 'test.txt';
$fp = fopen($path, 'rb');
$size = filesize($path);

$cheaders = array('Authorization: Bearer '.DROPBOX_APP_TOKEN,
    'Content-Type: application/octet-stream',
    'Dropbox-API-Path-Root: {".tag": "namespace_id", "namespace_id":"123456789"}',
    'Dropbox-API-Arg: {"path":"/test.txt","mode":{".tag":"add"}}');

$ch = curl_init('https://content.dropboxapi.com/2/files/upload');
curl_setopt($ch, CURLOPT_HTTPHEADER, $cheaders);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

echo $response;
curl_close($ch);
fclose($fp);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you target a folder at the Root of the dropbox account which has the namespace id of 123456789 in this example.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 09:05:07 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597489#M27769</guid>
      <dc:creator>lexomatic</dc:creator>
      <dc:date>2022-05-17T09:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Targeting a folder at the root of a business account.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597517#M27770</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1542551"&gt;@lexomatic&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;The error message, you have posted, provides a good guidance how to solve your issue. Doesn't adding the header missing with your user id, as asked, solve it? &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@9AD39CA637682E9616FBE31CDAF1B6C4/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 08:04:59 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597517#M27770</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-05-17T08:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Targeting a folder at the root of a business account.</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597578#M27773</link>
      <description>&lt;P&gt;That's correct, since your access token is connected to the team itself, you'll need to specify a particular member to use a user API endpoint like /2/files/upload. You can find more information on that in &lt;A href="https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access" target="_self"&gt;the documentation under the "Member file access" section&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 12:45:35 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Targeting-a-folder-at-the-root-of-a-business-account/m-p/597578#M27773</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-05-17T12:45:35Z</dc:date>
    </item>
  </channel>
</rss>

