RESTful knowledge exchange
Post Reply
judall
Lurker
Posts: 2
Liked: never
Joined: Oct 22, 2018 2:49 pm
Full Name: Jim Udall
Contact:

Create or update vcloud organization

Post by judall »

I'm trying to use the RESTful API to create/update an vCloud organization. I'm following the documentation very closely, but not succeeding in either case. If I try to create an Organization (which exists in vCloud), I formulate the following payload:

Code: Select all

<?xml version="1.0"?>
<VCloudOrganizationConfigCreateSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xds="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <OrganizationName>AmyotteCo-1526665147</OrganizationName>
    <BackupServerUid>urn:veeam:BackupServer:0fd15ba6-10b6-48cf-85e6-866d8a1500ff</BackupServerUid>
    <RepositoryUid>urn:veeam:Repository:1db3f4d3-72fb-4f8a-9738-39e0c077a67a</RepositoryUid>
    <QuotaGb>400</QuotaGb>
   <JobSchedulerType>Full</JobSchedulerType>
</VCloudOrganizationConfigCreateSpec>
I have a somewhat similar payload for update. Whether I POST or PUT to /vcloud/organizations, I receive a 400 result with the following error:

Specifiy VCloudOrganizationConfigCreateSpecType

I have run out of options for getting past this issue. Any ideas?
anthonyspiteri79
Veeam Software
Posts: 741
Liked: 207 times
Joined: Jan 14, 2016 6:48 am
Full Name: Anthony Spiteri
Location: Perth, Australia
Contact:

Re: Create or update vcloud organization

Post by anthonyspiteri79 »

Hey there Jim.

If you take a look here: https://anthonyspiteri.net/creating-pol ... -creation/ I include and link to code that does what you are trying to achieve with PowerShell. The XML contents are able to be deciphered though, so you should end up with a working example.
Anthony Spiteri
Regional CTO APJ & Lead Cloud and Service Provider Technologist
Email: anthony.spiteri@veeam.com
Twitter: @anthonyspiteri
judall
Lurker
Posts: 2
Liked: never
Joined: Oct 22, 2018 2:49 pm
Full Name: Jim Udall
Contact:

Re: Create or update vcloud organization

Post by judall »

Thanks for leaning in Anthony. Alas, your pointer has not yielded a solution yet. Specifically, I looked at the powershell script and include the following relevant portion:

#region: POST - Add vCloud Org
"`nCreate vCloud Org..."
[String] $URL = $Proto + "://" + $Server + ":" + $Port + "/api/vCloud/orgConfigs"
$VCloudOrganizationConfigCreate = @{uri = $URL;
Method = 'POST';
Headers = @{'X-RestSvcSessionId' = $AuthXML.Headers['X-RestSvcSessionId'];
'Content-Type' = 'application/xml'}
Body = @"
<VCloudOrganizationConfigCreateSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OrganizationName>$org</OrganizationName>
<BackupServerUid>$BRServerUID</BackupServerUid>
<RepositoryUid>$BRRepoUID</RepositoryUid>
<QuotaGb>$Quota</QuotaGb>
<TemplateJobUid>$BRJobUID</TemplateJobUid>
<JobSchedulerType>Full</JobSchedulerType>
</VCloudOrganizationConfigCreateSpec>
"@
}

$VCloudOrganizationConfigCreateXML = Invoke-RestMethod @VCloudOrganizationConfigCreate -ErrorAction Stop
#endregion

Which is remarkably close to my own construction. The two obvious differences for me are:
1. I was not including the header 'Content-Type'.
2. I was not including the TemplateJobUid tag in my XML

So I adjusted my code to add the Content-type. The XML does not require the TemplateJobUid (according to the documentation), but I added that tag anyway.

Alas the results were identical: <Error Message=\"Specify VCloudOrganizationConfigCreateSpecType\"

I can add that I'm using API v1.3. I don't know the differences between this and 1.2. However, if I switch to 1.2 I can't even authenticate against the API with the same credentials. So I'd prefer not to go down to figure out the differences in the API from 1.2 to 1.3
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests