Esempio n. 1
0
        /// <summary>
        /// POST a transaction to ArangoDB.
        /// </summary>
        /// <typeparam name="T">Type to use for deserializing the object returned by the transaction function.</typeparam>
        /// <param name="body">Object containing information to submit in the POST transaction request.</param>
        /// <returns>Response from ArangoDB after processing the request.</returns>
        public async Task <PostTransactionResponse <T> > PostTransactionAsync <T>(PostTransactionBody body)
        {
            var content = GetContent(body, true, true);

            using (var response = await _client.PostAsync(_transactionApiPath, content))
            {
                var stream = await response.Content.ReadAsStreamAsync();

                if (response.IsSuccessStatusCode)
                {
                    return(DeserializeJsonFromStream <PostTransactionResponse <T> >(stream));
                }
                var error = DeserializeJsonFromStream <ApiErrorResponse>(stream);
                throw new ApiErrorException(error);
            }
        }
 /// <summary>
 /// POST a transaction to ArangoDB.
 /// </summary>
 /// <typeparam name="T">Type to use for deserializing the object returned by the transaction function.</typeparam>
 /// <param name="body">Object containing information to submit in the POST transaction request.</param>
 /// <returns>Response from ArangoDB after processing the request.</returns>
 public virtual async Task <PostTransactionResponse <T> > PostTransactionAsync <T>(PostTransactionBody body, CancellationToken cancellationToken = default)
 {
     return(await PostRequestAsync(ApiRootPath, response => new PostTransactionResponse <T>(response), body, null,
                                   cancellationToken));
 }