Powershell - Invoke-RestMethod "Delete" Issue for Managed Domain

Description
I’m querying users with licenses and specific date since they past logged in.

I need to know where/how I can include the additional string “action=delete” when invoking the DELETE method via Powershell. Since we have a managed domain, the default use of DELETE does not work since it tries to disassociate the account rather than delete.

Error
REST call threw exception: ({“code”:1107,“message”:“You can not disassociate a user with managed domain.”}.Exception)

Which App Type (OAuth / Chatbot / JWT / Webhook)?
JWT

Which Endpoint/s?
https://api.zoom.us/v2/users

Screenshots (If applicable)
Snippet of code below

`#this is just an excerpt of my overall script
#in this section, if I need to DELETE a user where can I add action=delete?

$global:usersToHaveTheLicenseRemoved | % {
$currentUserId = $.id
$params = @{
URI = “$zoomUsersEndpoint/$currentUserId”
Method = ‘DELETE’
Headers = @{ Authorization = “Bearer $OAuthToken”
‘Content-Type’ = ‘application/json’ }
}
try {
$global:response = Invoke-RestMethod @params
}
catch {
Write-Host "REST call threw exception: ($
.Exception)"
$global:exc = $_
exit
}`.
image

Additional context

I just need to know how/where to include the action=delete string under this global.

Hey @CRodriguez,

The delete user API requires that the action be included as a query parameter:
image

You’ll want to add this to your request URL:
?action=delete

Let me know if this helps to clarify,
Will

Hi Will,

Thanks for the response. I’m having trouble understanding how this would be included. Where would the request URL be placed?

Would this be included in the “URI” under the Method Parameters? Example Below
URI = “$zoomUsersEndpoint/$currentUserId?action=delete”

Thanks.

Hi @CRodriguez,

That’s correct, this would be part of your URI variable within your params object.

Thanks!
Will

Thanks Will.

I’m confirming that adding the following under parameters did work for user deletion with the managed domain users.

URI = “$zoomUsersEndpoint/$currentUserId ?action=delete”

Awesome, glad that did the trick! :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.