Skip to content

Commit a65721e

Browse files
AlejandroPAlejandro Panizza Carve
and
Alejandro Panizza Carve
authored
Fix/decimal remote parameters format. (#1151)
* - Fix format of numeric with decimals in remote calls. * - Reformat code. --------- Co-authored-by: Alejandro Panizza Carve <[email protected]>
1 parent 7cb9e21 commit a65721e

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 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
{

0 commit comments

Comments
 (0)