Streaming live at 10am (PST)

How can I add option cms fields using nodejs webflow API

How can I update fields in option using API- nodejs.
I am unable to add values to it(tag) when I publish other values are updating fine. I am trying to use option for filtering. I looked into multi reference but it seems like it is only letting me import from another collection but I want to populate it with my script(updates every min from another api) containing tags for every item. I am trying to filter by tags but can’t find any reference even after long search and tries. It’s like you can’t but still want to try official forums one last time for help

code:-
webflow.createItem(collectionId:xxxxx,
fields:{name:name,
slug:id,
title:titlexxxx,
tags:??(option)}

my tags format which I am trying to add values are [‘automobile’,‘music’].
From fields documentation it should be string and array but I am unable to make it work.
All are strings only tag is option
for which one value i gave is default(value of option) since its not letting me create one without giving something. (created since api wont allow to feed values without creating one manually )

I found a workaround after some tries. But for this to work you need to set values if its option set values and in case of multi reference set new collection and reference it to the collection you want .
Then manually create item in your present collection and set values to one of the item or set multi reference values to the field. then when you call below function you can see the manual values(ids) you set in option field and array(ids) like format in case of multi references.

const items = webflow.items({ collectionId: ‘xxxxxxxxxxx’ }, { limit: 1 });
items.then(i => console.log(i[‘items’]))

Then you can use webflow.createitem and in fields
if its option
“category”:‘xxxxxxx’ (id you got by manually enterring information)
in case multi reference
“Tags”:[‘xxxxx’,‘xxxxx’] (you get multi ids)

You can use this predefined ids to update same future values. In short webflow assigns ids the first time you enter values which should be fixed

Note:- only works if you want to add automatic predefined values using api you need to set manually fields first and check ids. In case of multi reference you can automate but needed to create collection manually and can then enter items into it using webflow create item and then get ids webflow.items by above command and then assign the ids to your present collection lot of work to do…

Do let me know if anyone has better method .Since I am new to webflow api and couldnt find any solutions online I wanted to share my experience so that others wont experience similar problems