Skip to content

Commit

Permalink
Altinn2CodeList Retry without language when receiving 404 (#114)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivar <ivar.nesje@finanstilsynet.no>
  • Loading branch information
ivarne and ivarne authored Dec 15, 2022
1 parent 7c8669a commit 835365f
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public Altinn2MetadataApiClient(HttpClient client)
public async Task<MetadataCodelistResponse> GetAltinn2Codelist(string id, string langCode, int? version = null)
{
var response = await _client.GetAsync($"https://www.altinn.no/api/metadata/codelists/{id}/{version?.ToString() ?? string.Empty}?language={langCode}");
if(response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
response = await _client.GetAsync($"https://www.altinn.no/api/metadata/codelists/{id}/{version?.ToString() ?? string.Empty}");
}
response.EnsureSuccessStatusCode();
var codelist = await response.Content.ReadAsAsync<MetadataCodelistResponse>();
return codelist;
Expand Down

0 comments on commit 835365f

Please sign in to comment.