Active IQ Unified Manager Discussions

ActiveIQ Unified Manager API Calls are failing ErrorError 401 - Unauthorized

sudhir30
1,523 Views

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:

-----------------------------------

Version: 9.9
 
Please let me know what could be the issue, credential are local database admin credentials.
1 ACCEPTED SOLUTION

JohnChampion
1,430 Views

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')

View solution in original post

3 REPLIES 3

Ontapforrum
1,507 Views

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.

JohnChampion
1,431 Views

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')

sudhir30
1,423 Views

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

Public