protected static HttpResponseMessage SuccessMessageResponseWithBody <TContent>(TContent content) { var httpHesponseMessage = new HttpResponseMessage(HttpStatusCode.OK); httpHesponseMessage.Content = HttpContentConverter.ToJsonStringContent(content); return(httpHesponseMessage); }
async Task <HttpResponseMessage> IHttpClientCallback.SendBodyAndCheckStatus <TRequest>(IHttpClientWrapper clientWrapper, HttpMethod action, TRequest request, string url) { using (var content = HttpContentConverter.ToJsonStringContent(request)) { var requestMessage = CreateRequest(action, url, content); return(await SendRequestAndCheckStatus(clientWrapper, requestMessage)); } }
protected static HttpResponseMessage SuccessMessageResponseWithHeadersAndBody <TContent>(IDictionary <string, string> headers, TContent content) { var httpHesponseMessage = new HttpResponseMessage(HttpStatusCode.OK); httpHesponseMessage.Content = HttpContentConverter.ToJsonStringContent(content); foreach (var header in headers) { httpHesponseMessage.Headers.Add(header.Key, header.Value); } return(httpHesponseMessage); }
public async Task <SearchResponse> SearchAsync(SearchOptions searchOptions) { var content = HttpContentConverter.GetHttpContent(searchOptions); string urlParameters = await content.ReadAsStringAsync(); using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"search?{urlParameters}")) { var response = await _httpClient.SendAsync(requestMessage); string responseString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SearchResponse>(responseString)); } }