cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1272
Views
0
Helpful
1
Replies

Spark API [PowerShell] Removing a License

johnkuntz
Level 1
Level 1

We currently are setup to use the directory connector to sync our users from Active Directory to Cisco Spark. That is working now that a major bug was patched on Cisco's backend code. Anyway, we found out that when you remove a user in Active directory it removes the user from Spark (as expected). However it does not release the number assigned the that user.

My proposed solution was to use powershell and the spark APIs to remove the call license, as suggested by Cisco. This would release the number back to being available for use. Is it possible to unassign licenses using the Spark APIs, specifically for an AD synced user?

[UPDATE 1] Working with devsupport to work through this.

[UPDATE 2] I finally have this working with powershell. Below is my code in case anyone is interested.

<#

## Reference https://developer.ciscospark.com/getting-started.html

#>

## Organization ID

$orgID = "[ORG ID HERE]"

# Cisco Spark License IDs

$call = '[CALL LICENSE ID HERE]' # Cisco Spark Call License

$meet = '[MEETING LICENSE ID HERE]' # Cisco Spark 25 Meeting Party License

$message = '[MESSAGE LICENSE ID HERE]' # Cisco Spark Messaging

# Get-License Information

Invoke-RestMethod -uri "https://api.ciscospark.com/v1/licenses/" -ContentType application/json -Method Get -Headers @{Authorization = '[AUTH CODE HERE]'} | Select -ExpandProperty items | Out-Host

# Get Person

$sparkperson = Invoke-RestMethod -uri "https://api.ciscospark.com/v1/people/" -ContentType application/json -Method Get -Headers @{Authorization = '[AUTH CODE HERE]'} | Select -ExpandProperty items | ? {$_.emails -like '*bob.smith*'}

# Person Parameters

$params = @{

###Uncomment this out to add licenses ###'licenses'= @("$meet", "$message","$call")

'emails'="$($sparkperson.emails)"

'displayName'=$($sparkperson.displayName)

'firstName'=$($sparkperson.firstName)

'lastName'=$($sparkperson.lastName)

'orgId'=$($sparkperson.orgId)

} | ConvertTo-Json

# Update Person

Invoke-RestMethod -uri "https://api.ciscospark.com/v1/people/$($sparkperson.id)" -ContentType application/json -Method Put -Headers @{Authorization = '[AUTH CODE HERE]'} -Body $params

So In line 26 of the script, you can uncomment the line to add licenses. You can pick and choose which licenses you want to assign or not assign.

Message was edited by: John Kuntz Added powershell script

1 Reply 1

Thomas Scheible
Level 1
Level 1

hi,

thanks for the script, I've found quite little powerhell and spark. Unfortunately, I get the following message when running: Do you have a hint?

Invoke-RestMethod: {"message": "Request method 'PUT' not supported", "errors": [{"description": "Request method 'PUT' not supported"}]