Unsolved
2 Posts
0
821
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
No Events found!



Rainer_EMC
4 Operator
•
8.6K Posts
0
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
sachdevst
1 Rookie
•
1 Message
0
June 27th, 2024 11:54
Create a session to get these 2 cookies.