Strange behaviour API number type

I have created the following API call:

This is the id returned by the API call

But… when I print it or save in to a thing it gets converted somehow…

This is the result, its not the same number…:
image

The number shown in the window from the API Connector just represents the first item. If you scroll down in that window, you can click to view the full raw response. Check out the raw response to see if you need to filter it differently to retrieve (save/print) the correct ID.

Remember that when a response is a list, you may need to modify it to display a single item. For example: Moneybird- Get client’s id :first item


Gaby at Coaching No Code Apps (formerly Coaching Bubble)

Courses & Products, Tutorials, Private Coaching, and High-level Development

Start Learning Today :mortar_board:

Thanks! But… that’s not the issue, because when I retreive the data as text instead of as number I receive the correct value, I’m just not able to process it as it’s not a number. When I process it as number it’s somehow rounded, only the last digit changes…

243765307586381402 returns as 243765307586381400

and another one:
243768326066538181 returns as 243768326066538180
243774306145797831 returns as 243774306145797820
243774410927899795 returns as 243774410927899800

Well, these IDs should be treated as texts, not as numbers. (The rounding you are seeing is probably related to them being very large numbers and bumping up against precision limitations.)

The IDs – even though they only contain digit characters – are intended to be used as texts. It’s not like they have any use as numbers. (For example, you wouldn’t ever divide any of these numbers by something, nor would you round them, etc.) These are like phone numbers in that sense: Phone numbers are texts, not numeric values.

Edit: Aside – What’s going on here is Bubble’s API Connector is seeing that the JSON being returned here is all digits and it’s trying to be helpful… “Oh hai, this looks like a number, you might want to use it as a number.” But it’s wrong in this case and you just need to correct it (select text as the type).

Edit 2: Correction: Not sure Bubble actually does this ^^^. Anyway, treat these things as texts. :slight_smile:

So, do you need to do math with these IDs? If not, then Keith’s suggestion should help - change the data type in the API Connector response window from number to text.

Thanks Gaby and Keith,

I have changed everything to text (db entry and API call) and now it’s working like a charm :slight_smile:

Gr,

Wouter.

1 Like