From 1fe8f9d556ea22bc3e4e177265da6ace55346e3d Mon Sep 17 00:00:00 2001 From: Ivar Date: Tue, 13 Dec 2022 13:21:11 +0100 Subject: [PATCH] Altinn2CodeList Retry without language when receiving 404 --- .../Options/Altinn2Provider/Altinn2MetadataApiClient.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Altinn.App.Core/Features/Options/Altinn2Provider/Altinn2MetadataApiClient.cs b/src/Altinn.App.Core/Features/Options/Altinn2Provider/Altinn2MetadataApiClient.cs index 0e6bd7bb0..dfb9fafde 100644 --- a/src/Altinn.App.Core/Features/Options/Altinn2Provider/Altinn2MetadataApiClient.cs +++ b/src/Altinn.App.Core/Features/Options/Altinn2Provider/Altinn2MetadataApiClient.cs @@ -28,6 +28,10 @@ public Altinn2MetadataApiClient(HttpClient client) public async Task 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(); return codelist;