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 节点添加标题。

¥Add a heading with Notion node. 2. 选择要添加标题的资源:

¥Select the resource you want to add a heading to:

  • 要添加带有标题的新页面,请选择“页面”或“数据库页面”资源并执行“创建”操作。

    ¥To add a new page with a heading, select the Page or Database Page resources with the Create operation.

  • 要向现有页面添加标题,请选择“块”资源并执行“追加到”操作。

    ¥To add a heading to an existing page, select the Block resource with the Append After operation. 3. 选择添加块并将类型名称或 ID 设置为标题 1、标题 2 或标题 3。

¥Select Add Block and set the Type Name or ID to either Heading 1, Heading 2, or Heading 3. 4. 添加一个连接到 Notion 节点的 HTTP 请求 节点,并选择 GET 方法。

¥Add an HTTP Request node connected to the Notion node and select the GET method. 5. 将 URL 设置为 https://api.notion.com/v1/blocks/<block_ID>。例如,如果你向现有页面添加了标题,则可以使用以下 URL:https://api.notion.com/v1/blocks/{{ $json.results[0].id }}。如果你创建的是新页面而不是追加区块,则可能需要先查询页面内容以查找区块 ID。

¥Set the URL to https://api.notion.com/v1/blocks/<block_ID>. For example, if your added the heading to an existing page, you could use the following URL: https://api.notion.com/v1/blocks/{{ $json.results[0].id }}. If you created a new page instead of appending a block, you may need to discover the block ID by querying the page contents first. 6. 选择“预定义凭据类型”,并连接你现有的 Notion 凭据。

¥Select Predefined Credential Type and connect your existing Notion credentials. 7. 在 HTTP 请求节点之后添加一个 编辑字段(设置) 节点。

¥Add an Edit Fields (Set) node after the HTTP Request node. 8. 将 heading_1.is_toggleable 添加为新的布尔字段,并将其值设置为 true。根据需要将 heading_1 替换为不同的标题编号。

¥Add heading_1.is_toggleable as a new Boolean field set to true. Swap heading_1 for a different heading number as necessary. 9. 在编辑字段(设置)节点之后添加第二个 HTTP 请求节点。

¥Add a second HTTP Request node after the Edit Fields (Set) node. 10. 将“方法”设置为 PATCH,并将 https://api.notion.com/v1/blocks/{{ $json.id }} 用作 URL 值。

1
¥Set the **Method** to `PATCH` and use `https://api.notion.com/v1/blocks/{{ $json.id }}` as the **URL** value.
  1. 选择“预定义凭据类型”,并连接你现有的 Notion 凭据。

    ¥Select Predefined Credential Type and connect your existing Notion credentials. 12. 启用“发送正文”并设置参数。

    ¥Enable Send Body and set a parameter. 13. 将参数“名称”设置为 heading_1(将 heading_1 替换为你使用的标题级别)。

    ¥Set the parameter Name to heading_1 (substitute heading_1 for the heading level you are using). 14. 将参数“值”设置为 {{ $json.heading_1 }}(将 heading_1 替换为你使用的标题级别)。

    ¥Set the parameter Value to {{ $json.heading_1 }} (substitute heading_1 for the heading level you are using).

以上序列将创建一个常规标题块。它将查询新创建的标头,添加 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

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

¥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 节点之前检查数据,请使用 如果 节点检查字段是否未设置。这允许你使用 编辑字段(设置) 节点,在字段没有有效值时有条件地删除该字段。

¥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.