Skip to main content

Add decimal via api

  • April 17, 2021
  • 6 replies
  • 31 views

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

ScottWorld
Forum|alt.badge.img+35
  • Genius
  • 9808 replies
  • April 18, 2021

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"


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • April 18, 2021

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,


ScottWorld
Forum|alt.badge.img+35
  • Genius
  • 9808 replies
  • April 18, 2021

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 =>)


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • April 18, 2021

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.


  • Author
  • New Participant
  • 1 reply
  • April 18, 2021

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.


dilipborad
Forum|alt.badge.img+23
  • Brainy
  • 235 replies
  • April 19, 2021

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,


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.