If an API task is unsuccessful, the status parameter is set to failure and the Error element captures all the
details.
<?xml version="1.0" encoding="UTF-8"?>
<Response status="failure" isValidLicense="true"
<Error majorErrorCode="500" minorErrorCode="2014"
message="Hierarchy with id '1' does not exist." />
</Response>
Table
1‐2 explains the components of the Error element.
Table 1-2. Components of Error Element
Element
majorErrorCode
minorErrorCode
vendorSpecificErrorCode
(Optional)
message
ErrorStackTrace
Common Elements in the Request and Response XMLs
Table
1‐3 presents the common XML elements used by the request and response XMLs.
Table 1-3. Common Elements
Element
Request
Response
status
IsValidLicense
For an example request XML, see "Requests." For an example response XML, see "Responses."
Chargeback API Syntax
Each vCenter Chargeback API has the following syntax:
<HTTP_request_method> <Base_Url>/<API_signature>
For example, GET https://123.123.123.123/vCenter-CB/api/hierarchies
Table
1‐4 describes the components of vCenter Chargeback API syntax.
Table 1-4. API Syntax Components
Syntax Component
HTTP_request_method
Base_Url
API_signature
version
VMware, Inc.
xmlns="http://www.vmware.com/vcenter/chargeback/1.5.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Description
The class of the error. It represents the HTTP Status codes.
The API error code. For example, it can indicate that hierarchy creation failed.
A vendor or implementation‐specific error code that points to specific modules or parts
of the code, and can make problem diagnostics easier. For example, it can indicate if a
code snippet is a vCenter error code or a database error code.
A one‐line, human‐readable message that describes the error that occurred.
This element is present when the log level in Chargeback is set to Debug.
Description
An API request starts with this element.
An API response starts with this element.
Denotes whether API is successfully executed.
Indicates the status of the license. Value can be true or false.
Description
PUT, POST, GET, or DELETE
The URL of the Chargeback host. The base URL for vCenter Chargeback APIs is:
https://<Chargeback server IP>/vCenter-CB/api
For example, https://123.123.123.123/vCenter-CB/api
The URL path for a Chargeback API. For example, /hierarchies retrieves the
hierarchies added to the Chargeback server running on 123.123.123.123.
(Optional) API version. If you need to use Chargeback server 1.0.1, specify the version
as 1.0.1. If you do not specify the version, the API version will be considered as 1.5.0.
Chapter 1 vCenter Chargeback APIs
9