Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Knossos.NET/Models/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ private enum ApiMethod
Log.Add(Log.LogSeverity.Warning, "Nebula.Trinity()", "Nebula services has been disabled.");
return null;
}
using var request = new HttpRequestMessage();
try
{
var client = KnUtils.GetHttpClient();
Expand All @@ -765,9 +766,11 @@ private enum ApiMethod
return null;
}
}
client.DefaultRequestHeaders.Add("X-KN-TOKEN", apiUserToken);
request.Headers.Add("X-KN-TOKEN", apiUserToken);
}
client.Timeout = TimeSpan.FromSeconds(timeoutSeconds);
request.RequestUri = new Uri(apiURL + resourceUrl);
request.Content = data;
switch (method)
{
case ApiMethod.POST:
Expand All @@ -776,7 +779,8 @@ private enum ApiMethod
{
throw new ArgumentNullException(nameof(data));
}
var response = await client.PostAsync(apiURL + resourceUrl, data);
request.Method = HttpMethod.Post;
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
data.Dispose();
Expand Down Expand Up @@ -830,7 +834,8 @@ private enum ApiMethod
}
case ApiMethod.GET:
{
var response = await client.GetAsync(apiURL + resourceUrl);
request.Method = HttpMethod.Get;
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
Expand Down