IPO 11 REST API with Powershell

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • drueneuve
    Aspiring Member
    • Dec 2020
    • 2

    IPO 11 REST API with Powershell

    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
    Result :
    Status : 1
    Error :

    Request
    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
    Result :
    Status : 0
    Error : 401:UnAuthorized
    I have check that $tokenSDK contain cookies JSESSIONID, I don't understand how to maintain the session !
    Last edited by drueneuve; 01-14-2021, 09:36 AM.
  • drueneuve
    Aspiring Member
    • Dec 2020
    • 2

    #2
    The problem was the "group management api" must have "Web services/configuration read/write" enable. With that setting, the code above is Ok

    Comment

    Loading