public static async Task <TResult> PostAsync <TRequest, TResult>(this HttpClient httpClient, string url, TRequest request)
        {
            var requestJson    = SystemTextJsonSerializer.Serialize(request);
            var requestContent = GetJsonStringContent(requestJson);

            HttpResponseMessage httpResponseMessage;

            try
            {
                httpResponseMessage = await httpClient.PostAsync(url, requestContent).ConfigureAwait(false);
            }
            catch (HttpRequestException e)
            {
                throw BankIdApiException.Unknown(e);
            }

            await BankIdApiErrorHandler.EnsureSuccessAsync(httpResponseMessage).ConfigureAwait(false);

            var contentStream = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false);

            var deserializedContent = await SystemTextJsonSerializer.DeserializeAsync <TResult>(contentStream).ConfigureAwait(false);

            if (deserializedContent == null)
            {
                throw new Exception("Could not deserialize JSON response");
            }

            return(deserializedContent);
        }
        public static async Task <TResult> PostAsync <TRequest, TResult>(this HttpClient httpClient, string url, TRequest request)
        {
            var requestJson    = SystemRuntimeJsonSerializer.Serialize(request);
            var requestContent = GetJsonStringContent(requestJson);

            HttpResponseMessage httpResponseMessage;

            try
            {
                httpResponseMessage = await httpClient.PostAsync(url, requestContent).ConfigureAwait(false);
            }
            catch (HttpRequestException e)
            {
                throw BankIdApiException.Unknown(e);
            }

            await BankIdApiErrorHandler.EnsureSuccessAsync(httpResponseMessage).ConfigureAwait(false);

            var content = await httpResponseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false);

            return(SystemRuntimeJsonSerializer.Deserialize <TResult>(content));
        }