cancel
Showing results for 
Search instead for 
Did you mean: 

Ruckus VSZ-E API have some example or suggest?

ask_eye
New Contributor II
I want to make a program use Ruckus VSZ-E API on controller that can auto change guest-ssid password.
Have some example or suggest?
6 REPLIES 6

tony_heung
Contributor II
Try this python executable script.

#!/usr/bin/env python

import csv, threading, requests

host = '<>'
adminname = '<>'
adminpassword = '<>'
zoneid = '<>'
wlanid = '<>'
newwifikey = '<>'

def loginRuckus():
  import urllib3
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

  session = requests.session()
  urlsession = 'https://%s:8443/wsg/api/public/v8_0/session' % (host)

  response = session.post(urlsession, json={"username":adminname, "password":adminpassword }, verify=False)
  print(response.text)
  return session

def change_enc_key(session):
  url = 'https://%s:8443/wsg/api/public/v8_0/rkszones/%s/wlans/%s/encryption' % (host, zoneid, wlanid)
  response = session.patch(url, json={"method":"WPA2","passphrase":newwifikey},  verify=False)
  print(response.text)
  print(response)
  return

def main():
  change_enc_key(loginRuckus())
  return

if __name__ == '__main__':
  main()

dave_watkins_74
Contributor
Because I've just spent _way_ to much time trying to do this in powershell, I figured I'd share a working powershell example

# Queries vSZ controllers using powershell
$UrlBase = "https://vsz:8443/wsg/api/public";
$apiVer = "v8_0"
$Body = [pscustomobject]@{ 
username = 'admin'
password = 'admin'
timeZoneUtcOffset = "+08:00"
}
$json = $Body | ConvertTo-Json
$session = Invoke-WebRequest -Uri $UrlBase/$apiVer/session -Method Post -Body $json -ContentType 'application/json' -SessionVariable websession
# Translate Cookie header into useable string
$stringCookie = [string]$session.Headers["Set-Cookie"]
$cookie = $stringCookie.substring(0,($stringCookie.length - 21))
# Add cookie to header
$headers = @{}
$headers.Add("Cookie",$cookie)
Invoke-RestMethod -Uri $UrlBase/$apiVer/session -Method GET -Headers $headers -ContentType 'application/json' -WebSession $websession
Invoke-RestMethod -Uri $UrlBase/apiInfo -Method GET -Headers $headers -ContentType 'application/json' -WebSession $websession