1.0.1

VMware, Inc. 9
Chapter 1 vCenter Chargeback APIs
IfanAPItaskisunsuccessful,thestatusfieldissettofailureandtheErrorelementcapturesallthedetails
asexplainedinthetableprovidedafterthiscodesample.
<?xml version="1.0" encoding="UTF-8"?>
<Response status="failure" isValidLicense="true"
xmlns="http://www.vmware.com/vcenter/chargeback/1.0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Error majorErrorCode="500" minorErrorCode="2014"
message="Hierarchy with id '1' does not exist." />
</Response>
Common Elements in the Request and Response XMLs
ThecommonXMLelementsusedbytherequestandresponseXMLsarepresentedinthefollowingtable.
RefertotheearliersectionsforsamplerequestandresponseXMLs.
Chargeback API Syntax
EachvCenterChargebackAPIhasthissyntax:
<HTTP_request_method> <Base_Url>/<API_signature>?version=1.0.1
Forexample,GET https://123.123.123.123/vCenter-CB/api/hierarchies?version=1.0.1
Table 1-2. Components of Error Elements
Element Description
majorErrorCode Theclassoftheerror.ItrepresentstheHTTPStatuscodes.
minorErrorCode ThespecificAPIerrorcode.Forexample,itcanindicatethathierarchycreationfailed.
vendorSpecificErrorCode
(Optional)
Avendor/implementationspecificerrorcodethatpointstospecificmodules/partsofthe
codeandcanmakeproblemdiagnosticseasier.Forexample,itcanindicate
ifacode
snippetisavCentererrorcodeoraDatabaseerrorcode.
message Aoneline,humanreadablemessagethatdescribestheerrorthatoccurred.
ErrorStackTrace ThiselementispresentwhentheloglevelinChargebackissettoDebug.
Table 1-3. Common Elements
Element Description
Request AnAPIrequeststartswiththiselement.
Response AnAPIresponsestartswiththiselement.
status DenoteswhetherAPIissuccessfullyexecuted.
IsValidLicense Indicatesthestatusofthelicense.Valuecanbetrueorfalse.
Table 1-4. API Syntax Components
Syntax Component Description
HTTP_request_method PUT,POST,GET,orDELETE
Base_Url, TheURLoftheChargebackhost.ThebaseURLforvCenterChargebackAPIsis:
https://<Chargeback server IP>/vCenter-CB/api
Forexample,https://123.123.123.123/vCenter-CB/api
API_signature TheURLpathforaChargebackAPI.Forexample,/hierarchiesretrievesthe
hierarchiesaddedtotheChargebackserverrunningon123.123.123.123.
version APIversion.ForChargebackserver1.0.1,itneedsto
bepassedas1.0.1.