code: def format_payload(self, api_version, data):
          
          # Check if payload is for API v1 or API v2.
          if (api_version in (1, 2)):
              # Check if string type.
              if type(data) == str:
                  # Convert to dictionary.
                  logger.debug('Converting string to dict:\n%s' % data)
                  # Remove possible starting question mark & ending ampersands.
                  data = data.lstrip('?')
                  data = data.rstrip('&')
                  # Convert to dictionary.
                  data = parse_qs(data)
                  logger.debug('Converted:\n%s' % str(data))
          elif api_version in ('am', 'was', 'am2'):
              if type(data) == etree._Element:
                  logger.debug('Converting lxml.builder.E to string')
                  data = etree.tostring(data)
                  logger.debug('Converted:\n%s' % data)
          return data
docs: Return appropriate QualysGuard API call.