UNSOLVED

manmohangiri

updated

2 years ago

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