I created a sample HTTP Post function for the REST services in Cortex.   

The function requires a few parameters that are not listed

1.  URL to the page your are attempting to post to. example: "http://myISE/storage/allocations"

2.  Data you are attempting to post example listed as $post in the function: "volume=6001F930010310000195000200000000&arrayendpoint=2000001F930010A4&hostendpoint=100000051ED4469C&lun=2"

 

---------------------------------------------------

function Execute-HTTPPostCommand()

 {

param(

[string]$target = $null

)

$username = "administrator"

$password = "mypass"

$webRequest = [System.Net.WebRequest]::Create($target)

$webRequest.ContentType = "text/html"

$PostStr = [System.Text.Encoding]::UTF8.GetBytes($Post)

$webrequest.ContentLength = $PostStr.Length

$webRequest.ServicePoint.Expect100Continue = $false

$webRequest.Credentials = New-Object System.Net.NetworkCredential -ArgumentList $username, $password 

$webRequest.PreAuthenticate = $true

$webRequest.Method = "POST"

$requestStream = $webRequest.GetRequestStream()

$requestStream.Write($PostStr, 0,$PostStr.length)

$requestStream.Close()


    [System.Net.WebResponse]$resp = $webRequest.GetResponse();

    $rs = $resp.GetResponseStream();

    [System.IO.StreamReader]$sr = New-Object System.IO.StreamReader -argumentList $rs;

    [string]$results = $sr.ReadToEnd();

    return $results;

 }

------------------------------------------------------

To use the function, add the required variables and call the function

-------------------------------------------------------------

$post = "volume=6001F930010310000195000200000000&arrayendpoint=2000001F930010A4&hostendpoint=100000051ED4469C&lun=2"

$URL = "http://myise/storage/allocations"

Execute-HTTPPostCommand $URL

 

--------------------------------------------------------


Enjoy