following the api document NSP_8.3_Manager_API_Reference_Guide_revF_en-us
i am using the following power shell code to get session ID from my nps .
i able to get the uid and password from session api:
$UnsecurePassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$this.WebClient.Credentials = New-Object System.Net.NetworkCredential -ArgumentList @($this.Username, $UnsecurePassword)
$user = $this.Username
$pass = $UnsecurePassword
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$this.WebClient.Headers.Add('accept','application/vnd.nsm.v2.0+json')
$this.WebClient.Headers.add('Content-Type','application/json')
$this.WebClient.Headers.add('NSM-SDK-API',$base64)
$Session= $this.WebClient.DownloadString("https://$myServer/sdkapi/session")
# get the session uid and code correctly
$JsonSession = $Session | ConvertFrom-Json
$user=$JsonSession.userId
$pass= $JsonSession.session
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$this.NSMSDKAPI = $base64
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$this.WebClient.Headers.Add('accept','application/vnd.nsm.v2.0+json')
$this.WebClient.Headers.add('Content-Type','application/json')
$this.WebClient.Headers.add('NSM-SDK-API',$this.NSMSDKAPI)
$response = $this.WebClient.DownloadString("${url}?${query_string}")
i get the 401 unauthorized error
my user is defined as super user
what am i doing wrong ?
Moved to NSP forum
Peacekeeper, this is a duplicate post in the NSP forum, can we lock this one?
Sure
Corporate Headquarters
6220 America Center Drive
San Jose, CA 95002 USA