vCloud API Programming Guide
18 VMware, Inc.
Allrequiredelementsmustappearinrequestbodies.Allelementsthatappearinrequestbodiesmust
appearintheorderestablishedbytheschema,andwithcontentthatconformstothetypeconstraint
specifiedintheschema.See“SchemaValidation”onpage 142.
Authentication
HTTPcommunicationsbetweenavCloudclientandserveraretypicallysecuredwithSSL.Inaddition,the
vCloudAPIimplementsBasicHTTPAuthentication,asdefinedbyRFC2617,whichenablesaclienttoobtain
atokenthatitcanusetoauthenticateindividualHTTPrequests.
Toobtainanduseanauthenticationtoken,
aclientmustfirstdiscovertheserver’sloginURL,andthenPOST
aloginrequesttothatURL,supplyingthecredentialsofanauthorizeduser.
To obtain and use an authentication token
1MakeanAPIversionrequesttoavCloudservicetoobtaintheloginURLforthatservice.Formore
information,see“A P I Versioning”onpage 147.
2Make
anHTTPPOSTrequesttotheloginURL,asshowninExample 2‐1onpage 21.
Iftheauthenticationheaderismissing,theserverreturnsHTTPresponsecode401.
Ifthecredentialssuppliedintheauthenticationheaderareinvalid,theserverreturnsHTTPresponse
code401.
Iftherequestissuccessful,theserverreturnsHTTPresponsecode200(OK)andheadersthatinclude
anauthorizationheaderoftheform:
x-vcloud-authorization:
token
ThisheadermustbeincludedineachsubsequentvCloudAPIrequest.
TheresponsebodyisanOrgListelement,whichisalistofallorganizationsthattheusercanaccess.
Theauthenticationtokenexpiresafteraconfigurableintervalofclientinactivity.Thedefaultis30minutesafter
thetokeniscreated.After
thetokenexpires,allrequestsfailwithHTTPresponsecode401untiltheclientlogs
inagaintoobtainanewtoken.
Responses
AllresponsesincludeanHTTPstatuscodeand,unlessthestatuscodeis204(NoContent),aContent‐Type
header.Responsecontentdependsontherequest.Someresponsesincludeadocumentbody,someinclude
onlyaURL,andsomeareempty.
Status Codes
Table 1‐2liststhesubsetofHTTPstatuscodesthatavCloudAPIclientcanexpectinaresponse.
N
OTECertainadministrativeoperationshavespecialauthenticationrequirements.Formoreinformation,see
“AdministratorCredentialsandPrivileges”onpage 93.
Table 1-2. HTTP Status Codes Returned by the vCloud API
Status Code Status Description
200OK Therequestisvalidandwascompleted.Theresponseincludesadocumentbody.
201Created Therequestisvalid.TherequestedobjectwascreatedandcanbefoundattheURLspecifiedin
theLocationheader.
202Accepted Therequestisvalidandataskwascreatedtohandleit.Thisresponse
isusuallyaccompanied
byataskURL.
204NoContent Therequestisvalidandwascompleted.Theresponsedoesnotincludeabody.
303SeeOther TheresponsetotherequestcanbefoundattheURLspecifiedintheLocationheader .
400BadRequest Therequestbodyismalformed,incomplete,or
otherwiseinvalid.