Create Datacenter
If vSphere APIs begin with /rest (vs /api), any maps are consumed/returned instead as arrays of objects, each containing a key and a value property field.
Create a new datacenter in the vCenter inventory
Request
URLURL
https://{api_host}/rest/vcenter/datacenter
Header Parameters
Header Parameters
string
vmware-api-session-id
Required
Required session ID, obtained by first calling Create Session API
Example: b00db39f948d13ea1e59b4d6fce56389
Request Body
Request Body
DatacenterCreateRequestBody of type application/json (required){
"spec": {
"folder": "string",
"name": "string"
}
}
Response
Response
Response BodyResponse Body
200 OK returns
DatacenterCreateResponseBody
of type application/json
The identifier of the newly created datacenter The result will be an identifier for the resource type: Datacenter.
{
"value": "string"
}
string
value
Optional
The identifier of the newly created datacenter The result will be an identifier for the resource type: Datacenter.
cURL Command
curl -X POST -H "vmware-api-session-id: b00db39f948d13ea1e59b4d6fce56389" -H "Content-Type: application/json" -d '{"spec":{"folder":"string","name":"string"}}' https://{api_host}/rest/vcenter/datacenter
Errors
400
com.vmware.vapi.std.errors.invalid_argument : if the datacenter name is empty or invalid as per the underlying implementation.
if the folder is not specified and the system cannot choose a suitable one.
401
com.vmware.vapi.std.errors.unauthenticated : if the user can not be authenticated. | com.vmware.vapi.std.errors.unauthorized : if the user doesn't have the required privileges.
404
com.vmware.vapi.std.errors.error : if the system reports an error while responding to the request. | com.vmware.vapi.std.errors.not_found : if the datacenter folder cannot be found.
409
com.vmware.vapi.std.errors.already_exists : if a datacenter with the same name is already present.
503
com.vmware.vapi.std.errors.service_unavailable : if the system is unable to communicate with a service to complete the request.