![]() ![]() |
#1
|
|||
|
|||
![]()
Hi all
Does anybody have a sample code to run GET methode with powershell I succed with authentication but the GET return error 401 unauthorized Authentication Code:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $uri = "https://<IPAddress_IPO>:7070/WebManagement/ws/sdk" $authente = "/security/authenticate" $IPAdress = "/admin/v1/provisionIPAddress" $Text = "SDKUser:password" $Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text) $credentials = [Convert]::ToBase64String($Bytes) $headers = @{ "X-User-Client" = "Avaya-WebAdmin" "X-User-Agent" = "Avaya-SDKUser" "Content-Type" = "application/xml" "Authorization" = "Basic " + $credentials "Host" = "<IPAddress_IPO>:7070" } $response1 = invoke-restmethod -method GET -Uri ($uri+$authente) -sessionvariable tokenSDK -Headers $headers -SkipCertificateCheck write-host "Status : " $response1.response.status write-host "Error : " $response1.response.data.ws_object.SMAError.error.error_code Status : 1Request Code:
$response2 = Invoke-restmethod -method GET -Uri ($uri+$IPAdress) -Headers $headers -WebSession $tokenSDK -SkipCertificateCheck -MaximumRedirection 0 write-host "Status : " $response2.response.status write-host "Error : " $response2.response.data.ws_object.SMAError.error.error_code Status : 0I have check that $tokenSDK contain cookies JSESSIONID, I don't understand how to maintain the session ! Last edited by drueneuve; 01-14-2021 at 08:36 AM. |
Tags |
rest api |
Thread Tools | Search this Thread |
Display Modes | |
|
|