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");
|
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.");
|
_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.");
|
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 baseUrl = settings.BaseUrl.TrimEnd('/');
|
||||||
|
|
||||||
var request = new HttpRequestBuilder(baseUrl).Resource(resource).Accept(HttpAccept.Json)
|
var request = new HttpRequestBuilder(baseUrl).Resource(resource)
|
||||||
.SetHeader("X-Api-Key", settings.ApiKey).Build();
|
.Accept(HttpAccept.Json)
|
||||||
|
.SetHeader("X-Api-Key", settings.ApiKey)
|
||||||
|
.Build();
|
||||||
|
|
||||||
var response = _httpClient.Get(request);
|
var response = _httpClient.Get(request);
|
||||||
|
|
||||||
|
if ((int)response.StatusCode >= 300)
|
||||||
|
{
|
||||||
|
throw new HttpException(response);
|
||||||
|
}
|
||||||
|
|
||||||
var results = JsonConvert.DeserializeObject<List<TResource>>(response.Content);
|
var results = JsonConvert.DeserializeObject<List<TResource>>(response.Content);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
Loading…
Reference in New Issue