public ResponseModel <TResponse> Post <TResponse, TRequest>(string requestUri, TRequest request, bool runAsync = false) { using (var client = new CoreHttpClient(baseUri)) { //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", D2I_CommonTypes.D2I_Sessions.Token); var response = client.PostAsJsonAsync(requestUri, request).Result; var result = ReadAsync <TResponse>(response).Result; return(result); } }
public async Task <ResponseModel <TResponse> > PostAsync <TResponse, TRequest>(string requestUri, TRequest request, bool runAsync = true) { using (var client = new CoreHttpClient(baseUri)) { //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", D2I_CommonTypes.D2I_Sessions.Token); var response = await client.PostAsJsonAsync(requestUri, request) .ContinueWith(r => ReadAsync <TResponse>(r.Result)).ConfigureAwait(runAsync);; return(await response); } }