Re: Add decimal via api

1223 3
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

I am trying to add decimals with 5 or more decimal places. i used the currency field but i cannot add the data via api.

the value here is “gains”=>“0.00072333333333363115”
i get error Airrecord::Error (HTTP 422: INVALID_VALUE_FOR_COLUMN: Field “gains” cannot accept the provided value)

6 Replies 6

Which API are you using? It works fine for me using the REST API.

If you’re using the REST API, you need to use a colon (not a =>), like this:

"gains": "0.00072333333333363115"

That actually depends on the programming language that is calling the REST API. For example, PHP uses => in arrays.

I think that the issues is more likely that the code has the invalid data type. If your number is in quotes, then Airtable thinks that you are providing a text string, not a number. Try removing the quotes from the number.

Instead of …

Try …

"gains" => 0.00072333333333363115,

Ah, good to know! Thanks! Does PHP also use ‘=>’ for non-arrays, such as number/currency fields?

(I’m just using CURL, so I use : instead of =>)

I’m referring to a PHP array, which is part of the PHP language, and is unrelated to Airtable field types.

4 - Data Explorer
4 - Data Explorer

I am using ruby. i actually dont have quotes around the decimal.
tea=Tea.create(“Symbol” => row[“instrument”], “Date” => row[“entryTime”] ,“TradePattern” => row[“tradepattern”] ,“tradeid” => row[“id”],“position” => row[“entryQty”],“gains” => row[“gains”],“isopen” => row[“isopen”],“account” => row[“account”], “airtable_lastsynctime”=>currenttime)
The data is retrieved from database as a decimal.

I think the Suggestion by @kuovonne should be working.
It’s a problem with the data type of a particular field.

By default it’s automatically passed string, store it into a variable and make type conversion then put that variable in that proper place.