Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Code
--------------------
Function New-DropBoxUser { [CmdletBinding()]Param( [Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)] [string]$FullName) # Split name into username # $FirstName, $LastName = $FullName.split(' ') $UserName = ($FirstName[0]+$LastName).toLower() $email = "$UserName@mycomp.com"
$Body = @{ "new_members" = @(@{ "member_email" = $email; "member_given_name" = $FirstName; "member_surname" = $LastName; "send_welcome_email" = "true"; "role" = @{ ".tag" = "member_only" } }) } Write-Host '' Write-Host 'Creating DropBox User...' ` -ForegroundColor 'Yellow' ` -BackgroundColor 'Black'$AuthToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'$token = "Bearer $AuthToken" $response=Invoke-RestMethod ` -Method Post ` -Uri "https://api.dropboxapi.com/2/team/members/add" ` -Headers @{ Authorization = $token } ` -ContentType "application/json; charset=utf-8" ` -Body (ConvertTo-Json $Body) }
---------------------
Output:
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
The code wasn't pasted properly, so i can reckon. 🙂 Any idea what is the issue with the code?
Better, refer to Stack-Overflow - https://stackoverflow.com/questions/52029373/unable-to-get-past-the-400-error
I have posted there too.
Update
---------------------
Found the error, the error is for two lines within the $Body
1. "send_welcome_email"="true";
Error: Error in call to API function "team/members/add": request body: new_members.send_welcome_email: u'true' is not a valid boolean
2. "role" = @{".tag" = "member_only"}
Error: Error in call to API function "team/members/add": request body: new_members.role: unknown tag 'System.Collections.Hashtable'
Hope now someone can help with this, any idea?
It looks like you already got help with this on StackOverflow. As you found, whenever an API call fails, you should check the response body itself for a more detailed message.
In this case, the error indicated that there were unexpected values in the request. Specifically, you were passing in incorrect types for the "send_welcome_email" and "role" parameters.
Hi there!
If you need more help you can view your support options (expected response time for a 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!