Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
ActiveIQ Unified Manager API Calls are failing ErrorError 401 - Unauthorized
2023-06-23
08:19 AM
2,192 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! See The Solution
1 ACCEPTED SOLUTION
sudhir30 has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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')
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
sudhir30 has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
