I found one strange issue in postman. In below request amount is integer field.
{ "merchantId": 49, "amount": 020 }
When I pass Amount 020 instead of 20. In API controller I received amount 16. When I pass 0100 I receive 64.
If I pass in double quotes like "020" or "0100". Then I get 20 and 100.
Below is controller method and request class:
[HttpPost]
public IHttpActionResult Post(XXXXXXXXCommand command)
{
IHttpActionResult result = null;
using (_logger.PushWeb())
{
_logger.Info("POST request to /transactions/debits/accountsetup", command);
try
{
}
catch (MerchantNotFoundException ex)
{
_logger.Error("XXXX", ex);
}
}
return result;
}
[DataContract(Name = "XXXXCommand")]
public class XXXXXXCommand : CommandBase
{
/// <summary>
/// Merchant ID
/// </summary>
[DataMember(Name = "merchantId", Order = 1)]
public int MerchantId { get; set; }
/// <summary>
/// Transaction amount
/// </summary>
[DataMember(Name = "amount", Order = 2)]
public int Amount { get; set; }
}
It looks like postman bug.
Prefixing a number with 0 makes it interpreted as an octal number.
Octal number syntax uses a leading zero. If the digits after the 0 are outside the range 0 through 7, the number will be interpreted as a decimal number.
var n = 0755; // 493
var m = 0644; // 420
For more information see this link.