<?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 Re: Upload Files Function Powershell - Bad Request in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249586#M14342</link>
    <description>&lt;P&gt;Whenever debugging issues like this (or to retrieve the result, e.g., the file metadata, etc., even in the case of success) be sure to read the response body. It will contain more information, such as a specific error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your description though, it looks like the issue is that you're using a Business app with &lt;A href="https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access" target="_self"&gt;the team member file access feature&lt;/A&gt; without specifying the 'Dropbox-API-Select-User' header, which identifies which member of the Business team to operate on.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you should either add that header with the relevant member ID, or, if you only need to upload to a specific account anyway, &lt;A href="https://www.dropbox.com/developers/apps/create" target="_self"&gt;register a different app&lt;/A&gt;&amp;nbsp;with the full&amp;nbsp;Dropbox or app folder permission instead. Those aren't Business apps, and just operate on a single account instead of the whole team. They can still be linked to accounts on Business teams though.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2017 15:47:49 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2017-10-26T15:47:49Z</dc:date>
    <item>
      <title>Upload Files Function Powershell - Bad Request</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249576#M14341</link>
      <description>&lt;P&gt;I'm trying to upload files using Powershell to a folder inside our company Dropbox. I'm using a function I googled somewhere (I don't have the URL at hand, sorry about that):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function Upload-FileToDropbox { 

Param(
    [Parameter(Mandatory=$true)]
    [string]$SourceFilePath,
    [Parameter(Mandatory=$true)]
    [string]$TargetFilePath,
    [Parameter(Mandatory=$true)]
    [string]$DropBoxAccessToken
)

    $arg = '{ "path": "' + $TargetFilePath + '", "mode": "add", "autorename": true, "mute": false }'
    $authorization = "Bearer $DropBoxAccessToken"

    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Authorization", $authorization)
    $headers.Add("Dropbox-API-Arg", $arg)
    $headers.Add("Content-Type", 'application/octet-stream')
     
    Invoke-RestMethod -Uri https://content.dropboxapi.com/2/files/upload -Method Post -InFile $SourceFilePath -Headers $headers
}&lt;/PRE&gt;&lt;P&gt;For this script, I've created a new team app with Permission type&amp;nbsp;&lt;EM&gt;&lt;SPAN&gt;Team member file access&lt;/SPAN&gt;&lt;/EM&gt;, and requested an access token. For the parameters in this function, I'm using something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$SourceFilePath = "C:\TEMP\test.txt"
$TargetFilePath = "/IT/test.txt"&lt;/PRE&gt;&lt;P&gt;However, when I try to upload a file, I'm getting the following error:&lt;/P&gt;&lt;PRE&gt;Invoke-RestMethod : The remote server returned an error: (400) Bad Request.&lt;/PRE&gt;&lt;P&gt;I tried running the Invoke-RestMethod manually, creating the headers by hand, but I get the same error over and over again. What am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:17:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249576#M14341</guid>
      <dc:creator>PDanos</dc:creator>
      <dc:date>2019-05-29T09:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Upload Files Function Powershell - Bad Request</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249586#M14342</link>
      <description>&lt;P&gt;Whenever debugging issues like this (or to retrieve the result, e.g., the file metadata, etc., even in the case of success) be sure to read the response body. It will contain more information, such as a specific error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your description though, it looks like the issue is that you're using a Business app with &lt;A href="https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access" target="_self"&gt;the team member file access feature&lt;/A&gt; without specifying the 'Dropbox-API-Select-User' header, which identifies which member of the Business team to operate on.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you should either add that header with the relevant member ID, or, if you only need to upload to a specific account anyway, &lt;A href="https://www.dropbox.com/developers/apps/create" target="_self"&gt;register a different app&lt;/A&gt;&amp;nbsp;with the full&amp;nbsp;Dropbox or app folder permission instead. Those aren't Business apps, and just operate on a single account instead of the whole team. They can still be linked to accounts on Business teams though.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 15:47:49 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249586#M14342</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-10-26T15:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Upload Files Function Powershell - Bad Request</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249619#M14346</link>
      <description>&lt;P&gt;Hi Greg,&lt;BR /&gt;&lt;BR /&gt;Thank you so much for your help. I seemed to overlook completely the Dropbox-API-Select-User header in the documentation. Before digging into finding the memberID, I chose to follow your suggestion on registering a new app with Full Dropbox permissions, and it did the trick. I was able to upload with no problems.&lt;BR /&gt;&lt;BR /&gt;Also, it's good to know the code was good, so i don't have to change anything on that end.&lt;BR /&gt;&lt;BR /&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: I found the original link to the code I used for anyone else that wants to use it, and also, to give proper credit:&amp;nbsp;&lt;A href="http://laurentkempe.com/2016/04/07/Upload-files-to-DropBox-from-PowerShell/" target="_blank"&gt;http://laurentkempe.com/2016/04/07/Upload-files-to-DropBox-from-PowerShell/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 19:09:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/249619#M14346</guid>
      <dc:creator>PDanos</dc:creator>
      <dc:date>2017-10-26T19:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Upload Files Function Powershell - Bad Request</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/593050#M27589</link>
      <description>&lt;P&gt;Maybe something changed. When trying the above script, I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invoke-RestMethod : {"error_summary": "missing_scope/..", "error": {".tag": "missing_scope", "required_scope": "files.content.write"}}&lt;BR /&gt;At line:20 char:5&lt;BR /&gt;+ Invoke-RestMethod -Uri &lt;A href="https://content.dropboxapi.com/2/files/upl" target="_blank" rel="noopener"&gt;https://content.dropboxapi.com/2/files/upl&lt;/A&gt; ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could this be related with using TLS 1.2?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 08:21:47 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/593050#M27589</guid>
      <dc:creator>Danut</dc:creator>
      <dc:date>2022-04-25T08:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Upload Files Function Powershell - Bad Request</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/593178#M27595</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1537420"&gt;@Danut&lt;/a&gt; A TLS issue would fail earlier in the connection process, with a different kind of error. A 'missing_scope' error indicates that while the app is permitted to use that scope, the particular access token you're using to make the API call does not have that scope granted. Also, be aware that just adding a scope to your app via the &lt;A href="https://www.dropbox.com/developers/apps" target="_blank" rel="noopener noreferrer"&gt;App Console&lt;/A&gt; does not retroactively grant that scope to existing access tokens.&lt;BR /&gt;&lt;BR /&gt;That being the case, to make any API calls that require that scope, you'll need to get a new access token with that scope.&lt;BR /&gt;&lt;BR /&gt;Refer to the &lt;A href="https://developers.dropbox.com/oauth-guide" target="_blank" rel="noopener noreferrer"&gt;OAuth Guide&lt;/A&gt; and &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#authorization" target="_blank" rel="noopener noreferrer"&gt;authorization documentation&lt;/A&gt; for more information.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 15:40:19 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-Files-Function-Powershell-Bad-Request/m-p/593178#M27595</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-04-25T15:40:19Z</dc:date>
    </item>
  </channel>
</rss>

