def sendRequest( api_Request, xmlRequestData = nil )

      fire( "onSendRequest" )

      resetErrorInfo

      # set up the request
      getDBforRequestURL( api_Request )
      getAuthenticationXMLforRequest( api_Request )
      isHTMLRequest = isHTMLRequest?( api_Request )
      api_Request = "API_" + api_Request.to_s if prependAPI?( api_Request )

      xmlRequestData << toXML( :udata, @udata ) if @udata and @udata.length > 0
      xmlRequestData << toXML( :rdr, @rdr ) if @rdr and @rdr.length > 0
      xmlRequestData << toXML( :xsl, @xsl ) if @xsl and @xsl.length > 0
      xmlRequestData << toXML( :encoding, @encoding ) if @encoding and @encoding.length > 0

      if xmlRequestData
         @requestXML = toXML( :qdbapi, @authenticationXML + xmlRequestData )
      else
         @requestXML = toXML( :qdbapi, @authenticationXML )
      end

      @requestHeaders = @standardRequestHeaders
      @requestHeaders["Content-Length"] = "#{@requestXML.length}"
      @requestHeaders["QUICKBASE-ACTION"] = api_Request
      @requestURL = "#{@qbhost}#{@dbidForRequestURL}"

      printRequest( @requestURL, @requestHeaders,  @requestXML ) if @printRequestsAndResponses
      @logger.logRequest( @dbidForRequestURL, api_Request, @requestXML ) if @logger

      begin

         # send the request
         if USING_HTTPCLIENT
            response = @httpConnection.post( @requestURL, @requestXML, @requestHeaders )
            @responseCode = response.status
            @responseXML = response.content
         else  
            if Net::HTTP.version_1_2?
               response = @httpConnection.post( @requestURL, @requestXML, @requestHeaders )
               @responseCode = response.code
               @responseXML = response.body
            else
               @responseCode, @responseXML = @httpConnection.post( @requestURL, @requestXML, @requestHeaders )
            end	
         end
          
         printResponse( @responseCode,  @responseXML ) if @printRequestsAndResponses

         if not isHTMLRequest
            processResponse( @responseXML )
         end

      @logger.logResponse( @lastError, @responseXML ) if @logger

      fireDBChangeEvents

      rescue Net::HTTPBadResponse => error
         @lastError = "Bad HTTP Response: #{error}"
      rescue Net::HTTPHeaderSyntaxError => error
         @lastError = "Bad HTTP header syntax: #{error}"
      rescue StandardError => error
         @lastError = "Error processing #{api_Request} request: #{error}"
      end

      @requestSucceeded = ( @errcode == "0" and @lastError == "" )

      fire( @requestSucceeded ? "onRequestSucceeded" : "onRequestFailed" )

      if @stopOnError and !@requestSucceeded
         raise @lastError
      end
   end
def sendRequest( api_Request, xmlRequestData = nil )

      fire( "onSendRequest" )

      resetErrorInfo

      # set up the request
      getDBforRequestURL( api_Request )
      getAuthenticationXMLforRequest( api_Request )
      isHTMLRequest = isHTMLRequest?( api_Request )
      api_Request = "API_" + api_Request.to_s if prependAPI?( api_Request )

      xmlRequestData << toXML( :udata, @udata ) if @udata and @udata.length > 0
      xmlRequestData << toXML( :rdr, @rdr ) if @rdr and @rdr.length > 0
      xmlRequestData << toXML( :xsl, @xsl ) if @xsl and @xsl.length > 0
      xmlRequestData << toXML( :encoding, @encoding ) if @encoding and @encoding.length > 0

      if xmlRequestData
         @requestXML = toXML( :qdbapi, @authenticationXML + xmlRequestData )
      else
         @requestXML = toXML( :qdbapi, @authenticationXML )
      end

      @requestHeaders = @standardRequestHeaders
      @requestHeaders["Content-Length"] = "#{@requestXML.length}"
      @requestHeaders["QUICKBASE-ACTION"] = api_Request
      @requestURL = "#{@qbhost}#{@dbidForRequestURL}"

      printRequest( @requestURL, @requestHeaders,  @requestXML ) if @printRequestsAndResponses
      @logger.logRequest( @dbidForRequestURL, api_Request, @requestXML ) if @logger

      begin

         # send the request
         if USING_HTTPCLIENT
            response = @httpConnection.post( @requestURL, @requestXML, @requestHeaders )
            @responseCode = response.status
            @responseXML = response.content
         else  
            if Net::HTTP.version_1_2?
               response = @httpConnection.post( @requestURL, @requestXML, @requestHeaders )
               @responseCode = response.code
               @responseXML = response.body
            else
               @responseCode, @responseXML = @httpConnection.post( @requestURL, @requestXML, @requestHeaders )
            end	
         end
          
         printResponse( @responseCode,  @responseXML ) if @printRequestsAndResponses

         if not isHTMLRequest
            processResponse( @responseXML )
         end

      @logger.logResponse( @lastError, @responseXML ) if @logger

      fireDBChangeEvents

      rescue Net::HTTPBadResponse => error
         @lastError = "Bad HTTP Response: #{error}"
      rescue Net::HTTPHeaderSyntaxError => error
         @lastError = "Bad HTTP header syntax: #{error}"
      rescue StandardError => error
         @lastError = "Error processing #{api_Request} request: #{error}"
      end

      @requestSucceeded = ( @errcode == "0" and @lastError == "" )

      fire( @requestSucceeded ? "onRequestSucceeded" : "onRequestFailed" )

      if @stopOnError and !@requestSucceeded
         raise @lastError
      end
   end
Sends requests to QuickBase and processes the reponses.