使用Powershell

时间:2016-05-04 18:45:24

标签: powershell dropbox-api

如果您正在寻找让技术支持人员重新发送Dropbox邀请的方法,而不是让他们成为管理员并使用管理控制台,则以下代码将为他们提供该功能。

# Prompt for Team Member Management permission 
#$token = Read-Host -Prompt "Enter your Dropbox Business API App token (Team Member Management permission): " 
$token = "Bearer LFaDKviemndvsifm72vknmefbLhggLl6XX8p78dknvi3emvecdfUq8O0lQ2UEUE_QX9zh" #replace with your value

 # Prompt for Team Member email to send invitation 
 $EmailInvite = Read-Host -Prompt "Enter the email address to re-send the Dropbox invitation" 

 $object = New-Object psobject 

 $object | Add-Member -MemberType NoteProperty -Name '.tag' -Value "email"
 $object | Add-Member -MemberType NoteProperty -Name email -Value $EmailInvite


try {
 # Make API Call to resend invitation
 $InviteStatus = Invoke-RestMethod -Uri https://api.dropbox.com/2/team/members/send_welcome_email -Body (ConvertTo-Json $object) -ContentType application/json -Headers @{ 
                 Authorization = $token } -Method Post 

} catch {
# Caught an error, just display it as the web API sends it back.

#  Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__ 
#  Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription

$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();

$responseBody

}

1 个答案:

答案 0 :(得分:0)

只需将您为此代码生成的授权号码替换为您的Dropbox业务或企业团队(请参阅Dropbox.com/developer以获取更多相关信息)。