英文:
How to add new or existing multi-select tags when creating a page in Notion API?
问题
我无法找出如何在Notion API中创建页面时添加多选标签。单选标签非常容易添加:
"City": {
"select": {
"name": "New York"
}
}
但是我的尝试添加多选标签最终失败:
"City": {
"multi_select": {
"options": [
{
"name": "New York",
"color": "red"
},
{
"name": "Tbilisi",
"color": "gray"
}
]
}
}
这是我收到的错误消息:
{"object":"error","status":400,"code":"validation_error","message":"body failed validation. Fix one:\nbody.properties.City.title should be defined, instead was `undefined`.\nbody.properties.City.rich_text should be defined, instead was `undefined`.\nbody.properties.City.number should be defined, instead was `undefined`.\nbody.properties.City.url should be defined, instead was `undefined`.\nbody.properties.City.select should be defined, instead was `undefined`.\nbody.properties.City.multi_select should be an array, instead was `{\"options\":[{\"name\":\"apple\",\"color\":\"red\"},{\"name\":\"Ora...`.\nbody.properties.City.people should be defined, instead was `undefined`.\nbody.properties.City.email should be defined, instead was `undefined`.\nbody.properties.City.phone_number should be defined, instead was `undefined`.\nbody.properties.City.date should be defined, instead was `undefined`.\nbody.properties.City.checkbox should be defined, instead was `undefined`.\nbody.properties.City.relation should be defined, instead was `undefined`.\nbody.properties.City.files should be defined, instead was `undefined`.\nbody.properties.City.status should be defined, instead was `undefined`.\nbody.properties.Name.id should be defined, instead was `undefined`.\nbody.properties.Name.name should be defined, instead was `undefined`.\nbody.properties.Name.start should be defined, instead was `undefined`."}
你有一个可以正常工作的示例吗?
这是完整的数据载荷:
newPageData = {
"parent": { "database_id": 'some id' },
"properties": {
"Name": {
"title": [
{
"text": {
"content": "New page"
}
}
]
},
"City": {
"multi_select": {
"options": [
{
"name": "New York",
"color": "red"
},
{
"name": "Tbilisi",
"color": "gray"
}
]
}
},
"Date": {
"date": {
"start": "2023-02-06",
"end": None
}
},
"Link": {
"url": "example.info"
}
}
}
英文:
I can't figure out how to add multi-select tags when creating a page in Notion API. Single select tags are extremely easy to add:
"City": {
"select": {
"name": "New York",
}
}
But my attempts to add multi-select tags end up failing.
"City": {
"multi_select": {
"options": [
{
"name": "New York",
"color": "red"
},
{
"name": "Tbilisi",
"color": "gray"
}
]},
}
Here's the error I get
{"object":"error","status":400,"code":"validation_error","message":"body failed validation. Fix one:\nbody.properties.City.title should be defined, instead was `undefined`.\nbody.properties.City.rich_text should be defined, instead was `undefined`.\nbody.properties.City.number should be defined, instead was `undefined`.\nbody.properties.City.url should be defined, instead was `undefined`.\nbody.properties.City.select should be defined, instead was `undefined`.\nbody.properties.City.multi_select should be an array, instead was `{\"options\":[{\"name\":\"apple\",\"color\":\"red\"},{\"name\":\"Ora...`.\nbody.properties.City.people should be defined, instead was `undefined`.\nbody.properties.City.email should be defined, instead was `undefined`.\nbody.properties.City.phone_number should be defined, instead was `undefined`.\nbody.properties.City.date should be defined, instead was `undefined`.\nbody.properties.City.checkbox should be defined, instead was `undefined`.\nbody.properties.City.relation should be defined, instead was `undefined`.\nbody.properties.City.files should be defined, instead was `undefined`.\nbody.properties.City.status should be defined, instead was `undefined`.\nbody.properties.Name.id should be defined, instead was `undefined`.\nbody.properties.Name.name should be defined, instead was `undefined`.\nbody.properties.Name.start should be defined, instead was `undefined`."}
Do you have a working example of how it should be done?
Here's the full payload
newPageData = {
"parent": { "database_id": 'some id' },
"properties": {
"Name": {
"title": [
{
"text": {
"content": "New page"
}
}
]
},
"City": {
"multi_select": {
"options": [
{
"name": "New York",
"color": "red"
},
{
"name": "Tbilisi",
"color": "gray"
}
]},
},
"Date": {
"date": {
"start": "2023-02-06",
"end": None,
}
},
"Link": {
"url": "example.info"
}
}
}
答案1
得分: 3
"When populating / updating a Multi-Select property, you don't need to include "options"
or specify the option's colour so this should work -
"City": {
"multi_select": [
{
"name": "New York"
},
{
"name": "Tbilisi"
}
]
}
you should remove the first comma at the end of your list of options for the City property too -
]},
},
英文:
When populating / updating a Multi-Select property, you don't need to include "options"
or specify the option's colour so this should work -
"City": {
"multi_select": [
{
"name": "New York"
},
{
"name": "Tbilisi"
}
]
}
you should remove the first comma at the end of your list of options for the City property too -
]},
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论