Compare commits
2 Commits
2d5c318689
...
9c5fbc314f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c5fbc314f | |||
| 1f3778095c |
@@ -31,7 +31,7 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||||||
|
|
||||||
public async Task<List<IPGeoFeed>> GetGeoFeedData()
|
public async Task<List<IPGeoFeed>> GetGeoFeedData()
|
||||||
{
|
{
|
||||||
List<IPGeoFeed> geoFeed = new List<IPGeoFeed>();
|
List<IPGeoFeed> geoFeed = [];
|
||||||
using HttpClient client = httpClientFactory.CreateClient();
|
using HttpClient client = httpClientFactory.CreateClient();
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", configuration["APIKey"]);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", configuration["APIKey"]);
|
||||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
@@ -46,10 +46,13 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||||||
logger.LogDebug($"Making request to {uri}...");
|
logger.LogDebug($"Making request to {uri}...");
|
||||||
|
|
||||||
using HttpResponseMessage result = await client.GetAsync(uri);
|
using HttpResponseMessage result = await client.GetAsync(uri);
|
||||||
if (result.IsSuccessStatusCode)
|
if (!result.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
string stringResult = await result.Content.ReadAsStringAsync();
|
string stringResult = await result.Content.ReadAsStringAsync();
|
||||||
jsonData = JsonSerializer.Deserialize<NetboxData>(stringResult, new JsonSerializerOptions {
|
jsonData = JsonSerializer.Deserialize<NetboxData>(stringResult, new JsonSerializerOptions
|
||||||
|
{
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
|
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -83,7 +86,6 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||||||
uri = new Uri(jsonData.Next);
|
uri = new Uri(jsonData.Next);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user