This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Newtonsoft.Json;
|
||||
using Shared.Models;
|
||||
@@ -10,8 +12,12 @@ public abstract class ApiAccessLayer
|
||||
|
||||
protected ApiAccessLayer(string apiBaseUrl)
|
||||
{
|
||||
_httpClient = new HttpClient();
|
||||
_httpClient.BaseAddress = new Uri(apiBaseUrl);
|
||||
var handler = new HttpClientHandler()
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||
};
|
||||
_httpClient = new HttpClient(handler);
|
||||
_httpClient.BaseAddress = new Uri(apiBaseUrl, UriKind.Absolute);
|
||||
}
|
||||
|
||||
private async Task<HttpResponseWrapper> SendRequest(HttpRequestMessage message)
|
||||
@@ -53,12 +59,11 @@ public abstract class ApiAccessLayer
|
||||
{
|
||||
uri = QueryHelpers.AddQueryString(endpoint, queryParams);
|
||||
}
|
||||
|
||||
message.RequestUri = new Uri(uri);
|
||||
message.RequestUri = new Uri(uri, UriKind.Relative);
|
||||
message.Method = method;
|
||||
if (data != null)
|
||||
{
|
||||
message.Content = new StringContent(JsonConvert.SerializeObject(data));
|
||||
message.Content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
}
|
||||
|
||||
return message;
|
||||
|
||||
Reference in New Issue
Block a user