From e46b621a2ddc7e3374d867460cab7aa10e7421e2 Mon Sep 17 00:00:00 2001 From: Shaun McPeck Date: Wed, 1 Mar 2017 00:35:46 -0600 Subject: [PATCH] Needed to treat a 201 as success, too. + removed some commented out code. --- Ombi.Api/ApiRequest.cs | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/Ombi.Api/ApiRequest.cs b/Ombi.Api/ApiRequest.cs index bb4dabb0a..c399eae45 100644 --- a/Ombi.Api/ApiRequest.cs +++ b/Ombi.Api/ApiRequest.cs @@ -59,17 +59,7 @@ namespace Ombi.Api var response = client.Execute(request); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); - /** - if (response.ErrorException != null) - { - var message = "Error retrieving response. Check inner details for more info."; - Log.Error(response.ErrorException); - Log.Error(response.ErrorException.InnerException); - throw new ApiRequestException(message, response.ErrorException); - } - **/ - - if (response.StatusCode == HttpStatusCode.OK) + if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) return response.Data; else throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); @@ -89,17 +79,7 @@ namespace Ombi.Api var response = client.Execute(request); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); - /** - if (response.ErrorException != null) - { - Log.Error(response.ErrorException); - Log.Error(response.ErrorException.InnerException); - var message = "Error retrieving response. Check inner details for more info."; - throw new ApiRequestException(message, response.ErrorException); - } - **/ - - if (response.StatusCode == HttpStatusCode.OK) + if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) return DeserializeXml(response.Content); else throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}."); @@ -112,17 +92,7 @@ namespace Ombi.Api var response = client.Execute(request); Log.Trace($"Request made to {response.ResponseUri} with status code {response.StatusCode}. The response was {response.Content}"); - /** - if (response.ErrorException != null) - { - Log.Error(response.ErrorException); - Log.Error(response.ErrorException.InnerException); - var message = "Error retrieving response. Check inner details for more info."; - throw new ApiRequestException(message, response.ErrorException); - } - **/ - - if (response.StatusCode == HttpStatusCode.OK) + if (response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created) return JsonConvert.DeserializeObject(response.Content, _settings); else throw new ApiRequestException($"Got StatusCode={response.StatusCode} for {response.ResponseUri}.");