Getting Infinity issues from api response

Hi All,

I get this response from one of the integration, 

{
"media_id": 710511363345354753,
"media_id_string": "710511363345354753",
"size": 11065,
"expires_after_secs": 86400,
"image": {
"image_type": "image/jpeg",
"w": 800,
"h": 320
}
}

once get the response , i have to use the media_id value for passing as a request to another api. When i get that media_id, it is coming like infinity value(∞).

Can you please guide how can I get that value.

Regards,

Bhanu

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    These are your options:

    1 Use another API

    2 Figure out how to get the API to acknowledge a string because it has to be a string

    3 Create a Java plugin that can convert your media_id_string to a long numeral format

    Appian does not support that number.  710511363345354753 simply cannot ever be expressed as a literal numeric value with all it's digits in Appian no matter how hard you try.  You're at 710 quadrillion, and the max safe integer value for 64 bit Double type is only a little above 9 quadrillion; you can't even store that in the Decimal type accurately.  You're about two orders of magnitude above the maximum odd integer that will fit in the variable.  You'd need a Java BigDecimal or Java long type or a C# Decimal to have a hope of storing it all.  The makers of this API were honestly quite foolish to demand a numeric value this long.  An ID should never be a numeric value anyway.  I would never store a social security number as anything but a string, especially since social security numbers can begin with a zero.  The main problem is that leaving them as a numeric type can cause developers to mistakenly perform arithmetic on it.

    This is not Appian's fault.  This is the API's fault, honestly.  I don't understand either why the number is that large or even how it is that large.  How did they even return a JSON number that large?  Javascript uses exclusively 64 bit Double float type for numbers, so again wouldn't JSON have a cap at 9 quadrillion?

Reply
  • 0
    Certified Lead Developer

    These are your options:

    1 Use another API

    2 Figure out how to get the API to acknowledge a string because it has to be a string

    3 Create a Java plugin that can convert your media_id_string to a long numeral format

    Appian does not support that number.  710511363345354753 simply cannot ever be expressed as a literal numeric value with all it's digits in Appian no matter how hard you try.  You're at 710 quadrillion, and the max safe integer value for 64 bit Double type is only a little above 9 quadrillion; you can't even store that in the Decimal type accurately.  You're about two orders of magnitude above the maximum odd integer that will fit in the variable.  You'd need a Java BigDecimal or Java long type or a C# Decimal to have a hope of storing it all.  The makers of this API were honestly quite foolish to demand a numeric value this long.  An ID should never be a numeric value anyway.  I would never store a social security number as anything but a string, especially since social security numbers can begin with a zero.  The main problem is that leaving them as a numeric type can cause developers to mistakenly perform arithmetic on it.

    This is not Appian's fault.  This is the API's fault, honestly.  I don't understand either why the number is that large or even how it is that large.  How did they even return a JSON number that large?  Javascript uses exclusively 64 bit Double float type for numbers, so again wouldn't JSON have a cap at 9 quadrillion?

Children
No Data