Skip to content

Notion 节点常见问题(Notion node common issues)#

这里是一些关于 Notion 节点 的常见错误和问题,以及解决或排查它们的步骤。

🌐 Here are some common errors and issues with the Notion node and steps to resolve or troubleshoot them.

关系属性未显示(Relation property not displaying)#

Notion 节点仅支持显示 双向关系 的数据关联属性。当你将两个 Notion 数据库通过双向关系连接时,在使用 Notion 节点的 数据库页面 资源时,你可以选择或筛选关联属性。

🌐 The Notion node only supports displaying the data relation property for two-way relations. When you connect two Notion databases with a two-way relationship, you can select or filter by the relation property when working with the Notion node's Database Page resource.

要启用双向关系,请在 Notion 中编辑关系属性,并启用 在 [相关数据库名称] 上显示 选项以创建反向关系。选择一个名称以在新上下文中使用该关系。现在在 n8n 中筛选或选择时可以访问该关系。

🌐 To enable two-way relations, edit the relation property in Notion and enable the Show on [name of related database] option to create a reverse relation. Select a name to use for the relation in the new context. The relation is now accessible in n8n when filtering or selecting.

如果你需要处理具有单向关系的 Notion 数据库,可以使用 HTTP 请求 并使用你现有的 Notion 凭证。例如,要更新单向关系,你可以向以下 URL 发送 PATCH 请求:

🌐 If you need to work with Notion databases with one-way relationship, you can use the HTTP Request with your existing Notion credentials. For example, to update a one-way relationship, you can send a PATCH request to the following URL:

1
https://api.notion.com/v1/pages/<page_id>

启用 发送正文,将 正文内容类型 设置为 JSON,并将 指定正文 设置为 使用 JSON。之后,你可以在 JSON 字段中输入如下 JSON 对象:

🌐 Enable Send Body, set the Body Content Type to JSON, and set Specify Body to Using JSON. Afterward, you can enter a JSON object like the following into the JSON field:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
	"properties": {
		"Account": {
			"relation": [
				{
					"id": "<your_relation_ID>"
				}
			]
		}
	}
}

创建切换标题(Create toggle heading)#

Notion 节点允许你在向 页面数据库页面区块 资源添加区块时创建标题和可切换项。Notion 节点本身尚不支持创建可切换标题。

🌐 The Notion node allows you to create headings and toggles when adding blocks to Page, Database Page, or Block resources. Creating toggleable headings isn't yet supported by the Notion node itself.

你可以通过创建一个常规标题,然后修改它以启用 is_toggleable 属性 来解决这个问题:

🌐 You can work around this be creating a regular heading and then modifying it to enable the is_toggleable property:

  1. 使用 Notion 节点添加标题。
  2. 选择要添加标题的资源:
    • 要添加带有标题的新页面,请使用 创建 操作选择 页面数据库页面 资源。
    • 要向现有页面添加标题,请选择带有“追加到后”操作的区块资源。
  3. 选择 添加区块,并将 类型名称或 ID 设置为 标题 1标题 2标题 3
  4. 添加一个连接到 Notion 节点的 HTTP 请求 节点,并选择 GET 方法。
  5. URL 设置为 https://api.notion.com/v1/blocks/<block_ID>。例如,如果你在现有页面上添加了标题,可以使用以下 URL:https://api.notion.com/v1/blocks/{{ $json.results[0].id }}。如果你创建了一个新页面而不是追加一个区块,可能需要先通过查询页面内容来获取区块 ID。
  6. 选择 预定义凭据类型 并连接你现有的 Notion 凭据。
  7. 在 HTTP 请求节点之后添加一个 编辑字段(集合) 节点。
  8. 添加 heading_1.is_toggleable 作为一个新的 布尔 字段,并设置为 true。如有必要,将 heading_1 替换为不同的标题编号。
  9. 在“编辑字段(设置)”节点之后添加第二个 HTTP 请求节点。10. 将方法设置为 PATCH,并将 https://api.notion.com/v1/blocks/{{ $json.id }} 用作URL值。11. 选择预定义凭据类型,并连接你现有的 Notion 凭据。12. 启用发送正文并设置一个参数。13. 将参数名称设置为 heading_1(将 heading_1 替换为你正在使用的标题级别)。14. 将参数设置为 {{ $json.heading_1 }}(将 heading_1 替换为你正在使用的标题级别)。

上述序列将创建一个常规标题块。它将查询新创建的标题,添加 is_toggleable 属性,并更新标题块。

🌐 The above sequence will create a regular heading block. It will query the newly created header, add the is_toggleable property, and update the heading block.

处理空值(Handle null and empty values)#

在使用 Notion 节点时,如果提交的字段为空或为 null,您可能会收到验证错误。当您从前面的节点填充字段时,如果数据缺失,也可能会发生这种情况。

🌐 You may receive a validation error when working with the Notion node if you submit fields with empty or null values. This can occur any time you populate fields from previous nodes when that data is missing.

要解决此问题,请在将字段数据发送到 Notion 之前检查其是否存在,或使用默认值。

🌐 To work around this, check for the existence of the field data before sending it to Notion or use a default value.

在执行 Notion 节点之前检查数据,使用 If 节点来检查字段是否未设置。这允许你使用 Edit Fields (Set) 节点在字段没有有效值时有条件地移除该字段。

🌐 To check for the data before executing the Notion node, use an If node to check whether the field is unset. This allows you to use the Edit Fields (Set) node to conditionally remove the field when it doesn't have a valid value.

作为替代方案,如果传入的数据没有提供值,你可以设置一个默认值

🌐 As an alternative, you can set a default value if the incoming data doesn't provide one.