Dropbox API Sharing a folder Sharing a folder via HttpWebRequest in PowerShell

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

$url = "https://api.dropboxapi.com/2/sharing/share_folder"

$req = [System.Net.HttpWebRequest]::Create($url)
$req.headers["Authorization"] = "Bearer <ACCESS_TOKEN>"
$req.Method = "POST"
$req.ContentType = "application/json"
$enc = [system.Text.Encoding]::UTF8
$params = @{path="/new shared folder path"} | ConvertTo-Json -compress
$params = $enc.GetBytes($params)
$req.GetRequestStream().Write($params, 0, $params.Length)

$res = $req.GetResponse()
Write-Host "Response Status Code: "$res.StatusCode
Write-Host "Response Status Description: "$res.StatusDescription
$readStream = new-object System.IO.StreamReader $res.GetResponseStream()
$result = $readStream.ReadToEnd() | ConvertFrom-Json
Write-Host $result
$readStream.Close()
$res.Close()

<ACCESS_TOKEN> should be replaced with your access token.



Got any Dropbox API Question?