def send_request(url, args, url_params = {})
      method = args[:method]
      req_args = {}
      url_params = {} if url_params.nil?
      url_params[:key] = @security_token unless @security_token.nil?
      req_args[:query] = url_params if url_params.keys.length > 0

      req_args[:header] = setup_request_headers(args[:method])
      if (args[:method] == :post) || (args[:method] == :put)
        text_json = args[:payload].to_json
        req_args[:body] = text_json
      end

      begin
        log_info("Rally API calling #{method} - #{url} with #{req_args}\n With cookies: #{@rally_http_client.cookie_manager.cookies}")
        response = @rally_http_client.request(method, url, req_args)
      rescue Exception => ex
        msg =  "RallyAPI: - rescued exception - #{ex.message} on request to #{url} with params #{url_params}"
        log_info(msg)
        raise StandardError, msg
      end

      log_info("RallyAPI response was - #{response.inspect}")
      if response.status_code != 200
        msg = "RallyAPI - HTTP-#{response.status_code} on request - #{url}."
        msg << "\nResponse was: #{response.body}"
        raise StandardError, msg
      end

      json_obj = JSON.parse(response.body)   #todo handle null post error
      errs = check_for_errors(json_obj)
      raise StandardError, "\nError on request - #{url} - \n#{errs}" if errs[:errors].length > 0
      json_obj
    end
def send_request(url, args, url_params = {})
      method = args[:method]
      req_args = {}
      url_params = {} if url_params.nil?
      url_params[:key] = @security_token unless @security_token.nil?
      req_args[:query] = url_params if url_params.keys.length > 0

      req_args[:header] = setup_request_headers(args[:method])
      if (args[:method] == :post) || (args[:method] == :put)
        text_json = args[:payload].to_json
        req_args[:body] = text_json
      end

      begin
        log_info("Rally API calling #{method} - #{url} with #{req_args}\n With cookies: #{@rally_http_client.cookie_manager.cookies}")
        response = @rally_http_client.request(method, url, req_args)
      rescue Exception => ex
        msg =  "RallyAPI: - rescued exception - #{ex.message} on request to #{url} with params #{url_params}"
        log_info(msg)
        raise StandardError, msg
      end

      log_info("RallyAPI response was - #{response.inspect}")
      if response.status_code != 200
        msg = "RallyAPI - HTTP-#{response.status_code} on request - #{url}."
        msg << "\nResponse was: #{response.body}"
        raise StandardError, msg
      end

      json_obj = JSON.parse(response.body)   #todo handle null post error
      errs = check_for_errors(json_obj)
      raise StandardError, "\nError on request - #{url} - \n#{errs}" if errs[:errors].length > 0
      json_obj
    end
args should have :method