Active IQ Unified Manager Discussions
Active IQ Unified Manager Discussions
Hello All,
We are trying to access the unified manager API using the powershell, On the swagger page all is working as expected but when trying to call or open the uri links, we are receiving below errors.
> $url = "https://<IP-Address>/api/datacenter"
> $result = Invoke-RestMethod -Method 'GET' -Uri $url -header $header -Credential $cred -ContentType "application/JSON"
Invoke-RestMethod : Active IQ Unified Manager | ErrorError 401 - UnauthorizedPlease go back to the homepage and try again.
At line:1 char:11
+ $result = Invoke-RestMethod -Method 'GET' -Uri $url -header $header - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
>
Powershell Version:
--------------------------
Name : Windows PowerShell ISE Host
Version : 5.1.19041.2673
ActiveIQ Unified Manager:
-----------------------------------
Solved! See The Solution
For AIQUM, authentication is passed in the header of the request, not as a credential.
# Generate Authorization Header
$umInfo = "$um_login_account`:$um_login_password"
$umInfo = [System.Text.Encoding]::UTF8.GetBytes($umInfo)
$umInfo = [System.Convert]::ToBase64String($umInfo)
$umHeader = @{ 'Authorization' = ("Basic {0}" -f $umInfo); 'Content-Type' = 'application/json' }
...and Invoke-RestMethod...
$um_result = Invoke-RestMethod -Method Get -Uri $um_gw_url -Headers $umHeader -SkipCertificateCheck -ErrorAction Stop
(This is in PowerShell v7 so if you're using v5 remove the -SkipCertificateCheck and do the 'self-signed certificate hack')
Looking at the HTTP status code 401, it suggest - Unauthorized request
https://docs.netapp.com/us-en/active-iq-unified-manager-99/api-automation/reference-authentication-errors.html
I am not sure what is the exact requirement for API access but - Is the user exits in the AIUM with "Application Administrator" role? You could try to create one for accessing APIs.
For AIQUM, authentication is passed in the header of the request, not as a credential.
# Generate Authorization Header
$umInfo = "$um_login_account`:$um_login_password"
$umInfo = [System.Text.Encoding]::UTF8.GetBytes($umInfo)
$umInfo = [System.Convert]::ToBase64String($umInfo)
$umHeader = @{ 'Authorization' = ("Basic {0}" -f $umInfo); 'Content-Type' = 'application/json' }
...and Invoke-RestMethod...
$um_result = Invoke-RestMethod -Method Get -Uri $um_gw_url -Headers $umHeader -SkipCertificateCheck -ErrorAction Stop
(This is in PowerShell v7 so if you're using v5 remove the -SkipCertificateCheck and do the 'self-signed certificate hack')
Thankyou John,
I was able to figure it out by myself, after posting here it was due to the SSL certificate the page was throwing Error 401 - Unauthorized