From 94d6f2b6461688c7675564aba4d5930eefdb003e Mon Sep 17 00:00:00 2001 From: AlejandroP <apanizza@genexus.com> Date: Mon, 20 Nov 2023 11:33:59 -0300 Subject: [PATCH 1/3] - Add object Properties for remote API Call error, and response status --- .../GxClasses/Helpers/GXRestAPIClient.cs | 15 +++++++++------ .../GxClasses/Helpers/GxObjectProperties.cs | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs index bc372fc0b..914cce8f8 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs @@ -40,12 +40,12 @@ public GXRestAPIClient() public string ErrorMessage { get; set; } public int StatusCode { get; set; } - + public string StatusMessage { get ; set; } public int ResponseCode { get => responseCode; set => responseCode = value; } public string ResponseMessage { get => responseMessage; set => responseMessage = value; } public string HttpMethod { get => httpMethod; set => httpMethod = value; } - public string protocol = "REST"; + public int protocol = 1; private string httpMethod = "GET"; @@ -336,6 +336,9 @@ public void AddUploadFile(string FilePath, string name) public void RestExecute() { this.ErrorCode = 0; + this.ErrorMessage = ""; + this.StatusCode = 0; + this.StatusMessage = ""; _queryString = String.Empty; if (_queryVars.Count > 0) { @@ -380,16 +383,16 @@ public void RestExecute() serviceuri += "/" + this.Location.BaseUrl.TrimEnd('/').TrimStart('/') + "/" + this.Location.ResourceName; serviceuri += _queryString; httpClient.HttpClientExecute( this.HttpMethod, serviceuri); + this.ErrorCode = (httpClient.ErrCode == 0)? 1: httpClient.ErrCode; + this.ErrorMessage = httpClient.ErrDescription; + this.StatusCode = httpClient.StatusCode; + this.StatusMessage = httpClient.ReasonLine; if (httpClient.StatusCode >= 300 || httpClient.ErrCode > 0) { - this.ErrorCode = (httpClient.ErrCode == 0)? 1: httpClient.ErrCode; - this.ErrorMessage = httpClient.ErrDescription; - this.StatusCode = httpClient.StatusCode; _responseData = new Dictionary<string, object>(); } else { - this.StatusCode = httpClient.StatusCode; _responseData = GeneXus.Utils.RestAPIHelpers.ReadRestParameters(httpClient.ToString()); } } diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GxObjectProperties.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GxObjectProperties.cs index 01e9634cc..fa8bed4b1 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GxObjectProperties.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GxObjectProperties.cs @@ -10,16 +10,19 @@ namespace GeneXus.Application public class GxObjectProperties { private GxLocation location = null; - private string protocol = "rest"; + private int protocol = 1; private string errorMessage = String.Empty; private int errorCode = 0; private int statusCode = 0; + private string statusMessage = String.Empty; public GxLocation Location { get => location; set => location = value; } public string ErrorMessage { get => errorMessage; set => errorMessage = value; } public int ErrorCode { get => errorCode; set => errorCode = value; } public int StatusCode { get => statusCode; set => statusCode = value; } - public string Protocol { get => protocol; set => protocol = value; } + + public string StatusMessage { get => statusMessage; set => statusMessage = value; } + public int Protocol { get => protocol; set => protocol = value; } } public class GxObjectsConfiguration { From 00a0c2295024c6c3f712a12a0f54162d6536c67c Mon Sep 17 00:00:00 2001 From: AlejandroP <apanizza@genexus.com> Date: Sat, 25 Nov 2023 03:28:49 -0300 Subject: [PATCH 2/3] - In APIClient changed ErrorCode to be equal to the httpclient object --- dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs index 914cce8f8..a429508c6 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs @@ -383,7 +383,7 @@ public void RestExecute() serviceuri += "/" + this.Location.BaseUrl.TrimEnd('/').TrimStart('/') + "/" + this.Location.ResourceName; serviceuri += _queryString; httpClient.HttpClientExecute( this.HttpMethod, serviceuri); - this.ErrorCode = (httpClient.ErrCode == 0)? 1: httpClient.ErrCode; + this.ErrorCode = httpClient.ErrCode; this.ErrorMessage = httpClient.ErrDescription; this.StatusCode = httpClient.StatusCode; this.StatusMessage = httpClient.ReasonLine; From ddc4d3c6e4dfee71f9fa77c06fd6fe16b0c74295 Mon Sep 17 00:00:00 2001 From: Alejandro Panizza Carve <apanizza@genexus.com> Date: Thu, 25 Apr 2024 16:55:18 -0300 Subject: [PATCH 3/3] Change port for Net core --- .../src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs index dbbdf8f64..000729f1a 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs @@ -29,7 +29,11 @@ public GXRestAPIClient() Location.BaseUrl = "api"; Location.Host = "www.example.com"; Location.ResourceName = "service"; +#if NETCORE + Location.Port = 8082; +#else Location.Port = 80; +#endif }