Building JSON Request Bodies
Last Updated December 16, 2024

Methods are invoked with the JSON protocol by sending a POST request with the method name in the URL and the method parameters in the body of the request.
The request body for a method invocation is a single JSON object containing the method parameters as named objects or arrays. For instance, a request body for the
MoveIntoFolder_Task
method might look like this:
{'list': [
    {'_typeName': 'ManagedObjectReference',
    'type': 'VirtualMachine',
    'value': 'vm-23'},
    {'_typeName': 'ManagedObjectReference',
    'type': 'VirtualMachine',
    'value': 'vm-96'},
    {'_typeName': 'ManagedObjectReference',
    'type': 'VirtualApp',
    'value': 'resgroup-v44'}
  ]
}
The method name itself becomes part of the URL, as described in Building JSON Request URLs.
Use the WSDL forms of type names. WSDL names are shown in the
vSphere Web Services API
reference. For example, use the WSDL name
ApplyHostProfileConfigurationSpec
, rather than the package name
vim.profile.host.ProfileManager.ApplyHostConfigSpec
, to build a data object as a parameter to the method
ApplyEntitiesConfig_Task
. Similarly, use the method's WSDL name,
ApplyEntitiesConfig_Task
, rather than the source name,
applyEntitiesConfiguration
.