Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Parsing a JSON array into a "Multiple Select" field through the curl API

Topic Labels: API
1531 1
cancel
Showing results for 
Search instead for 
Did you mean: 

I’m trying to create a record using the curl API, and one of the fields in my record is of type “Multiple Select”. The possible values are integers (formatted as strings since that’s the only option for this field), so it’s supposed to be entered as [“1”,“2”,“3”] etc. However, I am using an integration that only supports mustache formatting, and with mustache, JSON arrays get parsed as [1,2,3] and this is not accepted by the API. I’ve tried setting “typecast”:true and it doesn’t work.

Is there another way of accomplishing what I’m trying to do here?

1 Reply 1

On a limb here, these issues always confuse me. Does this help?

var json = '{"prop":{"options":[1,2,3]}}'; // string
var obj  = JSON.parse(json);               // parsed
var data = {options: obj.prop['options'].map(function(x){ return {name: '"' + x + '"'}; })};

Which returns this -

{options=[{name="1"}, {name="2"}, {name="3"}]}