Skip to content

Commit b4cd4a4

Browse files
author
Alejandro Panizza Carve
committed
- - Brin changes from [Fix/decimal remote parameters format. #1151] to U13
1 parent 3c146b1 commit b4cd4a4

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
67
using GeneXus.Utils;
78
using GeneXus.Http.Client;
9+
810
using System.Web;
11+
912
using GeneXus.Mime;
13+
14+
using System.Globalization;
15+
1016
#if NETCORE
1117
using System.Text.Json;
1218
using System.Text.Json.Serialization;
@@ -371,8 +377,21 @@ public Guid GetBodyGuid(string varName)
371377
}
372378

373379
public Decimal GetBodyNum(string varName)
374-
{
375-
return Decimal.Parse( GetJsonStr(varName), System.Globalization.NumberStyles.Float);
380+
{
381+
try
382+
{
383+
return Decimal.Parse(GetJsonStr(varName), NumberStyles.Float, CultureInfo.InvariantCulture);
384+
}
385+
catch (FormatException)
386+
{
387+
Console.WriteLine("Failed to parse number due to format exception.");
388+
}
389+
catch (OverflowException)
390+
{
391+
Console.WriteLine("Failed to parse number due to overflow exception.");
392+
}
393+
// Return a empty value in case of an exception
394+
return 0m;
376395
}
377396
public long GetBodyLong(string varName)
378397
{
@@ -542,12 +561,10 @@ public void RestExecute()
542561
this.StatusMessage = httpClient.ReasonLine;
543562
if (httpClient.StatusCode >= 300 || httpClient.ErrCode > 0)
544563
{
545-
546564
_responseData = new Dictionary<string, object>();
547565
}
548566
else
549567
{
550-
551568
_responseData = GeneXus.Utils.RestAPIHelpers.ReadRestParameters(httpClient.ToString());
552569
}
553570
}

0 commit comments

Comments
 (0)