Fancier output
This commit is contained in:
parent
17206bfb8c
commit
2c7da0352b
@ -26,14 +26,18 @@ public static class ApiHttpClient
|
|||||||
new StringContent(jsonContent, Encoding.UTF8, new MediaTypeHeaderValue("application/json"));
|
new StringContent(jsonContent, Encoding.UTF8, new MediaTypeHeaderValue("application/json"));
|
||||||
foreach ((string, string) customHeader in customHeaders)
|
foreach ((string, string) customHeader in customHeaders)
|
||||||
request.Headers.Add(customHeader.Item1, customHeader.Item2);
|
request.Headers.Add(customHeader.Item1, customHeader.Item2);
|
||||||
logger?.Log(LogLevel.Debug, $"Request-URI: {request.RequestUri}\n\r" +
|
logger?.Log(LogLevel.Debug, $"Request: \n" +
|
||||||
$"Request-Headers: \n\t{string.Join("\n\t", request.Headers.Select(h => $"{h.Key} {string.Join(", ", h.Value)}"))}\n\r" +
|
$"-URI: {request.RequestUri}\n" +
|
||||||
$"Request-Content: {request.Content?.ReadAsStringAsync().Result}");
|
$"-Headers: \n\t{string.Join("\n\t", request.Headers.Select(h => $"{h.Key} {string.Join(", ", h.Value)}"))}\n" +
|
||||||
|
$"-Content: {request.Content?.ReadAsStringAsync().Result}");
|
||||||
|
|
||||||
HttpClient httpClient = new();
|
HttpClient httpClient = new();
|
||||||
HttpResponseMessage response = httpClient.Send(request);
|
HttpResponseMessage response = httpClient.Send(request);
|
||||||
logger?.Log(!response.IsSuccessStatusCode ? LogLevel.Error : LogLevel.Debug,
|
logger?.Log(!response.IsSuccessStatusCode ? LogLevel.Error : LogLevel.Debug,
|
||||||
$"{request.RequestUri} response: {response.StatusCode}");
|
$"Response: \n" +
|
||||||
|
$"-URI: {request.RequestUri}\n" +
|
||||||
|
$"-Headers: \n\t{string.Join("\n\t", response.Headers.Select(h => $"{h.Key} {string.Join(", ", h.Value)}"))}\n" +
|
||||||
|
$"-Content: {response.Content?.ReadAsStringAsync().Result}");
|
||||||
httpClient.Dispose();
|
httpClient.Dispose();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user