AnsweredAssumed Answered

Use REST api to create volume for VMWare.

Question asked by Erik Snijder on Apr 21, 2016
Latest reply on May 13, 2016 by Rick van Vliet



Currently we are using a powershell script with a SSH plugin to create a volume for VMWare. We would like to start using the REST api but we are unable to find how to add several parameter on creation of the volume.


The current SSH script:






        $plinkarrayoptions="$nimarray -l $nimuser -pw $nimpw"

        $remotecmd1="vol --create $NimVolName --size $volsizeMB --perfpolicy VMware\ ESX\ 5 --initiatorgrp SEN\-VMNIMG\-C01\-R630 --multi_initiator 1"

        $command1=$plink+" "+$plinkarrayoptions+" "+$remotecmd1+" "

        $msg=Invoke-Expression -command $command1 -ErrorAction SilentlyContinue


We are using the following REST api script:


     [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

     # Get Token

     $array = "xxx"

     $username = "xxx"

      $password = "xxx"


$data = @{

    username = $username

  password = $password


$body = convertto-json (@{ data = $data })


$uri = "https://" + $array + ":5392/v1/tokens"

$token = Invoke-RestMethod -Uri $uri -Method Post -Body $body

$token = $


# Create a Volume


$data = @{

    name = $nimvolname

  size = $volsizeMB



$body = convertto-json (@{ data = $data })

$header = @{ "X-Auth-Token" = $token }

$uri = "https://" + $array + ":5392/v1/volumes"

$result = Invoke-RestMethod -Uri $uri -Method Post -Body $body -Header $header


$ | select name,size,serial_number | format-table -autosize


We need to add the parameters in italic in the SSH script to REST api script.

Could someone assist us?