Jump to content
Welcome to our new Citrix community!
  • 0

REST API - Add specified machine to specified Delivery Group not working


Remi Roy1709163296

Question

Hi,

 

I try to achieve the following :

 

Add specified machine to specified Delivery Group using the following reference :

DeliveryGroups_DoAddMachines

Instead of adding the specified VM, it always take the first one available in the same Machine Catalogue.

 

Using the following powershell code :

 

where $mc is the machine catalogue name as a string

where $dg is the delivery group name as a string

where $vmane is the machine name from the machine catalogue

 

$dgdd=@{
    "MachineCatalog"=$mc;
    "Count"="1";
    "AssignMachinesToUsers"=@{
        Machine = $vmname
    }
  }
$vm_to_dg = Invoke-RestMethod "https://api.cloud.com/cvad/manage/DeliveryGroups/$dg/Machines" -Method Post -Headers $global:headers -ContentType "application/json" -Body ($dgdd | ConvertTo-Json -Depth 10)


From the schema in the documentation this should be the way of doing it. The command do not return any error.

From the log i can see the call being made, but the action add the first available machine inside the machine catalog not the specified available one.

 

Is there something I'm missing? Do someone know how to make it work?

Thank! :)

Link to comment

2 answers to this question

Recommended Posts

  • 0

So i figured it out, the issue was that I was missing the square bracket [ ]


The json output was like this before :
 

{
    "MachineCatalog":  "MC-1234",
    "Count":  "1",
    "AssignMachinesToUsers":  
                                  {
                                      "Machine":  "vm1234"
                                  }
                              
}

 

 

Needed to be with the square brackets like this :
 

{
    "MachineCatalog":  "MC-1234",
    "Count":  "1",
    "AssignMachinesToUsers":  [
                                  {
                                      "Machine":  "vm1234"
                                  }
                              ]
}

 

 

The powershell code needed to achieve this :
 

$list = New-Object System.Collections.ArrayList
$list.Add(@{"Machine"=$vmname;})
$dgdd = @{"AssignMachinesToUsers"=$list;"MachineCatalog"=$mc;"Count"="1";}


$vm_to_dg = Invoke-RestMethod "https://api.cloud.com/cvad/manage/DeliveryGroups/$dg/Machines" -Method Post -Headers $headers -ContentType "application/json" -Body ($dgdd | ConvertTo-Json -Depth 10)


Hope it help someone in the future.

Link to comment
  • 0

Even after passing below object in body i get the error: "ErrorMessage": "Invalid arguments specified.\r\nParameter name: request". 

{

    "MachineCatalog": "catalogid",

    "AssignMachinesToUsers": [

        {

            "Machine":  "domain\VDI"

        }

    ]

}

 

Where am i going wrong?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...