{"record":{"id":"80c4171a0a9a5eef","repo":"Sonarr/Sonarr","slug":"simkl-api-call-resulted-in-an-unexpected-statuscod","errorCode":null,"errorMessage":"Simkl API call resulted in an unexpected StatusCode [{0}]","messagePattern":"Simkl API call resulted in an unexpected StatusCode \\[(.+?)\\]","errorType":"exception","errorClass":"ImportListException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Core/ImportLists/Simkl/SimklParser.cs","lineNumber":77,"sourceCode":"                foreach (var show in jsonResponse.Shows)\n                {\n                    series.AddIfNotNull(new ImportListItemInfo\n                    {\n                        Title = show.Show.Title,\n                        TvdbId = int.TryParse(show.Show.Ids.Tvdb, out var tvdbId) ? tvdbId : 0,\n                        ImdbId = show.Show.Ids.Imdb,\n                    });\n                }\n            }\n\n            return series;\n        }\n\n        protected virtual bool PreProcess(ImportListResponse netImportResponse)\n        {\n            if (netImportResponse.HttpResponse.StatusCode != HttpStatusCode.OK)\n            {\n                throw new ImportListException(netImportResponse, \"Simkl API call resulted in an unexpected StatusCode [{0}]\", netImportResponse.HttpResponse.StatusCode);\n            }\n\n            if (netImportResponse.HttpResponse.Headers.ContentType != null && netImportResponse.HttpResponse.Headers.ContentType.Contains(\"text/json\") &&\n                netImportResponse.HttpRequest.Headers.Accept != null && !netImportResponse.HttpRequest.Headers.Accept.Contains(\"text/json\"))\n            {\n                throw new ImportListException(netImportResponse, \"Simkl API responded with html content. Site is likely blocked or unavailable.\");\n            }\n\n            return true;\n        }\n    }\n}\n","sourceCodeStart":59,"sourceCodeEnd":90,"githubUrl":"https://github.com/Sonarr/Sonarr/blob/da2284d7eaab22ed9b2ca698af690148d691e967/src/NzbDrone.Core/ImportLists/Simkl/SimklParser.cs#L59-L90","documentation":"Thrown as an ImportListException during the PreProcess step of the Simkl import list parser when the HTTP response from the Simkl API has a status code other than 200 OK. This is the same guard pattern used across all import list parsers — it ensures the API is reachable before attempting to parse the JSON response.","triggerScenarios":"The Simkl API endpoint returns a non-200 status: 401 (API key invalid or expired), 403 (forbidden), 429 (rate limited), 500/502/503 (Simkl server error). The actual status code is formatted into the exception message.","commonSituations":"The Simkl API key (client ID) is missing or invalid in the import list settings, the Simkl user token has expired, the Simkl service is down, or network connectivity to simkl.com is blocked.","solutions":["Verify the Simkl API key and user token are correctly configured in the import list settings","Check the full exception message for the specific status code","Test connectivity to api.simkl.com from the Sonarr server","Re-authenticate with Simkl if the token has expired"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check Simkl API key and token before fetching\nif (string.IsNullOrWhiteSpace(settings.ApiKey))\n{\n    _logger.Warn(\"Simkl API key is not configured.\");\n    return new ImportListFetchResult();\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = simklImport.Fetch();\n}\ncatch (ImportListException ex) when (ex.Message.Contains(\"unexpected StatusCode\"))\n{\n    _logger.Warn(ex, \"Simkl API returned non-200 status. Check API key and token.\");\n}","preventionTips":["Verify the Simkl API key (client ID) is correctly configured","Re-authenticate with Simkl periodically to keep the access token fresh","Monitor Simkl API status pages for outages"],"tags":["simkl","http","status-code","api","import-list"],"backgroundTag":null,"analyzedSha":"da2284d7eaab22ed9b2ca698af690148d691e967","analyzedAt":"2026-08-13T15:53:02.562Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}