Skip to content

Commit 94d6f2b

Browse files
committed
- Add object Properties for remote API Call error, and response status
1 parent b111547 commit 94d6f2b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

dotnet/src/dotnetframework/GxClasses/Helpers/GXRestAPIClient.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public GXRestAPIClient()
4040
public string ErrorMessage { get; set; }
4141

4242
public int StatusCode { get; set; }
43-
43+
public string StatusMessage { get ; set; }
4444
public int ResponseCode { get => responseCode; set => responseCode = value; }
4545
public string ResponseMessage { get => responseMessage; set => responseMessage = value; }
4646
public string HttpMethod { get => httpMethod; set => httpMethod = value; }
4747

48-
public string protocol = "REST";
48+
public int protocol = 1;
4949

5050
private string httpMethod = "GET";
5151

@@ -336,6 +336,9 @@ public void AddUploadFile(string FilePath, string name)
336336
public void RestExecute()
337337
{
338338
this.ErrorCode = 0;
339+
this.ErrorMessage = "";
340+
this.StatusCode = 0;
341+
this.StatusMessage = "";
339342
_queryString = String.Empty;
340343
if (_queryVars.Count > 0)
341344
{
@@ -380,16 +383,16 @@ public void RestExecute()
380383
serviceuri += "/" + this.Location.BaseUrl.TrimEnd('/').TrimStart('/') + "/" + this.Location.ResourceName;
381384
serviceuri += _queryString;
382385
httpClient.HttpClientExecute( this.HttpMethod, serviceuri);
386+
this.ErrorCode = (httpClient.ErrCode == 0)? 1: httpClient.ErrCode;
387+
this.ErrorMessage = httpClient.ErrDescription;
388+
this.StatusCode = httpClient.StatusCode;
389+
this.StatusMessage = httpClient.ReasonLine;
383390
if (httpClient.StatusCode >= 300 || httpClient.ErrCode > 0)
384391
{
385-
this.ErrorCode = (httpClient.ErrCode == 0)? 1: httpClient.ErrCode;
386-
this.ErrorMessage = httpClient.ErrDescription;
387-
this.StatusCode = httpClient.StatusCode;
388392
_responseData = new Dictionary<string, object>();
389393
}
390394
else
391395
{
392-
this.StatusCode = httpClient.StatusCode;
393396
_responseData = GeneXus.Utils.RestAPIHelpers.ReadRestParameters(httpClient.ToString());
394397
}
395398
}

dotnet/src/dotnetframework/GxClasses/Helpers/GxObjectProperties.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ namespace GeneXus.Application
1010
public class GxObjectProperties
1111
{
1212
private GxLocation location = null;
13-
private string protocol = "rest";
13+
private int protocol = 1;
1414
private string errorMessage = String.Empty;
1515
private int errorCode = 0;
1616
private int statusCode = 0;
17+
private string statusMessage = String.Empty;
1718

1819
public GxLocation Location { get => location; set => location = value; }
1920
public string ErrorMessage { get => errorMessage; set => errorMessage = value; }
2021
public int ErrorCode { get => errorCode; set => errorCode = value; }
2122
public int StatusCode { get => statusCode; set => statusCode = value; }
22-
public string Protocol { get => protocol; set => protocol = value; }
23+
24+
public string StatusMessage { get => statusMessage; set => statusMessage = value; }
25+
public int Protocol { get => protocol; set => protocol = value; }
2326
}
2427

2528
public class GxObjectsConfiguration {

0 commit comments

Comments
 (0)