Fixed: Treat redirects as errors in Sonarr Import List
This commit is contained in:
parent
19b8fbe13b
commit
059a156f4a
|
@ -69,6 +69,12 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
|||
return new ValidationFailure("ApiKey", "API Key is invalid");
|
||||
}
|
||||
|
||||
if (ex.Response.HasHttpRedirect)
|
||||
{
|
||||
_logger.Error(ex, "Sonarr returned redirect and is invalid");
|
||||
return new ValidationFailure("BaseUrl", "Sonarr URL is invalid, are you missing a URL base?");
|
||||
}
|
||||
|
||||
_logger.Error(ex, "Unable to connect to import list.");
|
||||
return new ValidationFailure(string.Empty, $"Unable to connect to import list: {ex.Message}. Check the log surrounding this error for details.");
|
||||
}
|
||||
|
@ -90,11 +96,18 @@ namespace NzbDrone.Core.ImportLists.Sonarr
|
|||
|
||||
var baseUrl = settings.BaseUrl.TrimEnd('/');
|
||||
|
||||
var request = new HttpRequestBuilder(baseUrl).Resource(resource).Accept(HttpAccept.Json)
|
||||
.SetHeader("X-Api-Key", settings.ApiKey).Build();
|
||||
var request = new HttpRequestBuilder(baseUrl).Resource(resource)
|
||||
.Accept(HttpAccept.Json)
|
||||
.SetHeader("X-Api-Key", settings.ApiKey)
|
||||
.Build();
|
||||
|
||||
var response = _httpClient.Get(request);
|
||||
|
||||
if ((int)response.StatusCode >= 300)
|
||||
{
|
||||
throw new HttpException(response);
|
||||
}
|
||||
|
||||
var results = JsonConvert.DeserializeObject<List<TResource>>(response.Content);
|
||||
|
||||
return results;
|
||||
|
|
Loading…
Reference in New Issue