mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Fixed: Treat redirects as errors in Sonarr Import List
(cherry picked from commit 059a156f4a34c6b9cbe139fa1973b814e8a534ae) Closes #3799
This commit is contained in:
parent
75862028a2
commit
8624e044c8
1 changed files with 19 additions and 6 deletions
|
@ -69,13 +69,19 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
||||||
return new ValidationFailure("ApiKey", "API Key is invalid");
|
return new ValidationFailure("ApiKey", "API Key is invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Error(ex, "Unable to send test message");
|
if (ex.Response.HasHttpRedirect)
|
||||||
return new ValidationFailure("ApiKey", "Unable to send test message");
|
{
|
||||||
|
_logger.Error(ex, "Lidarr returned redirect and is invalid");
|
||||||
|
return new ValidationFailure("BaseUrl", "Lidarr 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.");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "Unable to send test message");
|
_logger.Error(ex, "Unable to connect to import list.");
|
||||||
return new ValidationFailure("", "Unable to send test message");
|
return new ValidationFailure(string.Empty, $"Unable to connect to import list: {ex.Message}. Check the log surrounding this error for details.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -90,11 +96,18 @@ namespace NzbDrone.Core.ImportLists.Lidarr
|
||||||
|
|
||||||
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…
Add table
Add a link
Reference in a new issue