I’m building a Discord bot that creates entries in Notion using the notion-py library. Everything works fine except for one issue - I can’t figure out how to properly populate a multi-select column.
Here’s my current setup:
def create_notion_entry():
view = client.get_collection_view(database_url[current_type])
new_row = view.collection.add_row()
new_row.url_field = stored_url
new_row.title_field = stored_title
if current_type == 1:
new_row.category_field = stored_category
tag_list = stored_tags.split(',')
for single_tag in tag_list:
# Need to populate multi-select field called "Labels"
set_multiselect_option("Labels", single_tag)
I found a helper function online but it throws an error:
def set_multiselect_option(property_name, option_value):
schema = view.collection.get(["schema"])
property_config = next(
(v for k, v in schema.items() if v["name"] == property_name), None
)
if property_config["type"] != "multi_select":
raise ValueError(f"Property {property_name} is not multi-select")
property_config["options"].append({
"id": str(uuid1()),
"value": option_value,
"color": "default"
})
collection.set("schema", schema) # This line fails
The error message says “Not allowed to edit column: schema”. How can I properly assign values to a multi-select column in Notion using the notion-py library?