Пример #1
0
        async Task <Card> PostCard(Card card)
        {
            HttpRequestMessage request() =>
            new HttpRequestMessage(HttpMethod.Post, new Uri("/api/card", UriKind.Relative))
            {
                Content = ToJsonContent(card).HttpContent
            };
            var response = await sessionManager.Send(request);

            return(JsonConvert.DeserializeObject <Card>(response));
        }
Пример #2
0
        async Task <Card> PostCard(Card card)
        {
            HttpRequestMessage request() =>
            new HttpRequestMessage(HttpMethod.Post, new Uri("/api/card", UriKind.Relative))
            {
                Content = ToJsonContent(card).HttpContent
            };
            var response = await sessionManager.Send(request);

            try
            {
                return(JsonConvert.DeserializeObject <Card>(response));
            }
            catch (JsonSerializationException e)
            {
                throw new MetabaseApiException($"Error parsing response for {nameof(Card)} from:\n{response}", e);
            }
        }