Exemple #1
0
        public async Task <string> PostAsync(
            string requestPath,
            object data,
            IHeaderDictionary headers = null)
        {
            string responseText;

            var requestUrl = Defaultpath + requestPath;

            try
            {
                responseText = await RequestSender.SendRequestAsync(requestUrl, "Post", data, headers);
            }
            catch (WebRequestException ex)
            {
                var msg = $"Error occured during request. Url: {ex.Url}. Message: {ex.Message}";

                throw new ServiceCommunicationException(msg);
            }

            return(responseText);
        }
Exemple #2
0
        public async Task <TResponse> PostAsync <TResponse, TRequest>(
            string requestPath,
            TRequest data,
            IHeaderDictionary headers = null)
        {
            string responseText;

            var requestUrl = Defaultpath + requestPath;

            try
            {
                responseText = await RequestSender.SendRequestAsync(requestUrl, "Post", data, headers);
            }
            catch (Exception ex)
            {
                var msg = $"Error occured during request.  Message: {ex.Message}";

                throw new Exception(msg);
            }

            var result = DeserializeResponse <TResponse>(responseText);

            return(result);
        }