<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def invoke(self, request):
 # type: (ApiClientRequest) -> ApiClientResponse """Dispatches a request to an API endpoint described in the request. Resolves the method from input request object, converts the list of header tuples to the required format (dict) for the `requests` lib call and invokes the method with corresponding parameters on `requests` library. The response from the call is wrapped under the `ApiClientResponse` object and the responsibility of translating a response code and response/ error lies with the caller. :param request: Request to dispatch to the ApiClient :type request: ApiClientRequest :return: Response from the client call :rtype: ApiClientResponse :raises: :py:class:`ask_sdk_core.exceptions.ApiClientException` """

        try:
            http_method = self._resolve_method(request)
            http_headers = self._convert_list_tuples_to_dict(
                headers_list=request.headers)

            parsed_url = parse_url(request.url)
            if parsed_url.scheme is None or parsed_url.scheme != "https":
                raise ApiClientException(
                    "Requests against non-HTTPS endpoints are not allowed.")

            if request.body:
                body_content_type = http_headers.get("Content-type", None)
                if (body_content_type is not None and
                        "json" in body_content_type):
                    raw_data = json.dumps(request.body)
                else:
                    raw_data = request.body
            else:
                raw_data = None

            http_response = http_method(
                url=request.url, headers=http_headers, data=raw_data)

            return ApiClientResponse(
                headers=self._convert_dict_to_list_tuples(
                    http_response.headers),
                status_code=http_response.status_code,
                body=http_response.text)
        except Exception as e:
            raise ApiClientException(
                "Error executing the request: {}".format(str(e)))