
UNSOLVED
M
manmohangiri
2 Posts
0
846
July 16th, 2021 08:00
Unity API expecting cookies in the header
Team,
I tried to execute the below code in powershell but it gives 401 unauthorized error, I believe we need to pass Cookie header as part of the request.
Could you please explain how to populate the cookie header for MOD_AUTH_CAS_S and mod_sec_emc
$EncodedAuthorization = [ System.Text.Encoding ]::UTF8.GetBytes( 'username@domain.com' + ':' + 'xyz' )
$EncodedPassword = [ System.Convert ]::ToBase64String( $EncodedAuthorization )
$Server = "domain.com"
$REST_URI = 'https://' + $Server + '/api/types/pool/instances'
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "application/json")
$headers.Add("Content-type", "application/json")
$headers.Add("X-EMC-REST-CLIENT", "true")
$headers.Add("Authorization", "Basic $EncodedPassword")
$response = Invoke-RestMethod $REST_URI -Method 'GET' -Headers $headers
$response | ConvertTo-Json
1 person also has this problem
Responses (2)
Solutions (0)

Rainer_EMC
6 Operator
•
8645 Posts
616
0
Posted July 26th, 2021 02:00
I havent used powershell for REST but yes you need to login and store that info in order to issue REST calls
Nothing special there for Unity
Maybe you want to try the PowerShell Module for Unity from here
https://dl.dell.com/downloads/DL104725_PowerShell-Module-for-Dell-EMC-Unity-1.0.msi?language=en_US