Article ID: 116506, created on Jul 19, 2013, last review on May 10, 2014

  • Applies to:
  • Operations Automation

Symptoms


As Provider I want to send OpenAPI request to POA on Windows Management Node, which does not have curl installed out of the box.

Resolution


Either download curl for Windows or use PowerShell function like below:

function POA_API($filename, $uri="http://localhost:8440/RPC2")
{

    $request = [System.Net.WebRequest]::Create($uri)
    $request.ContentType = "application/x-www-form-urlencoded"
    $request.Method = "POST"

    $buffer = [Byte[]]$(Get-Content -Path $filename -Encoding byte -ReadCount 0)

    $reqstr = $request.GetRequestStream()
    $reqstr.Write($buffer, 0, $buffer.Length)
    $reqstr.Close()

    $response = (new-object System.IO.StreamReader($request.GetResponse().GetResponseStream())).ReadToEnd()

    return $response
}


Copy and paste function definition to PowerShell window and it is ready for use. Pass the path to the file with OpenAPI XML request as an argument to the POI_API function:
PS C:\Users\Parallelsadmin> POA_API("C:\Users\Administrator\pem.getAccountInfo.xml")
<?xml version="1.0" encoding="utf-8"?>
<methodResponse><params><param><value><struct><member><name>result</name><value><struct><member><name>account_type</name><value><string>C</string></value></member><member><name>address</name><value><struct><member><name>address2</name><value><string></string></value></member><member>....

5356b422f65bdad1c3e9edca5d74a1ae caea8340e2d186a540518d08602aa065 e12cea1d47a3125d335d68e6d4e15e07

Email subscription for changes to this article
Save as PDF