我在 Notion.so 上创建了一个集成
我使用以下 URL添加到 Notion获得了临时 OAuth 代码
上面的 URL,在从 Notion UI 授权后,现在给我下面的代码,
XXXXXXX-XXXXXXX
使用上面步骤中的代码来获取授权代码
POST https://api.notion.com/v1/oauth/token HTTP/1.1
Authorization: Basic XXXXXXXOnNlY3JldF9DeXp0d1A0TVNLZkZIY0XXXXXXXXX
Content-Type: application/json
Content-Length: 164
{
"grant_type": "authorization_code",
"code": "XXXXXX-XXXXX",
"redirect_uri": "http://localhost:8080/api/notion/auth/callback"
}
Run Code Online (Sandbox Code Playgroud)
这个回应在
{
"error": "invalid_grant"
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
提前致谢!
API:关系属性
好的
我正在将信息发送到概念表。我遇到的问题是关系属性。
我尝试过传递名称、传递 id,但找不到正确的调用。有没有人有一个示例或链接来报告如何使用它们。执行查询时,该字段返回空,因此它不能作为示例。
例子:
{
"parent": {
"type": "database_id",
"database_id": "538dfa97-b0f3-4df6-8388-9dbd16f50ad7"
},
"properties": {
"Nombre Tarea": {
"title": [
{
"type": "text",
"text": { "content": "TAREAS 1" }
}
]
},
"Asignado": { "multi_select": [ { "name": "" } ] },
"Origen": { "select": { "name": "Trabajo" } },
"Cliente": { "relation": { "name": "CLM" } }
}
}
or change
"Cliente": { "relation": [{ "id":"Usal-2b240920b9554e869b0a49b30d433cef" } ]}
The answers are:
{
"object": "error",
"status": 400,
"code": "validation_error", …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试使用 notions API 下载网站/页面。我分享了该页面并尝试了以下操作:
(async () => {
const pageId = 'abcd-editorial-efe.notion.site/Sites-abc123';
const response = await notion.pages.retrieve({ page_id: pageId });
console.log(response);
})();
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:
@notionhq/client warn: request fail {
code: 'object_not_found',
message: 'Could not find page with ID: abc123..... Make sure the relevant pages and databases are shared with your integration.'
}
Run Code Online (Sandbox Code Playgroud)
这是检索页面的正确 API 端点吗?
Notions docs pageId 是一个 GUID...但是当我共享我的页面时,我得到了一个完整的 URL:
(async () => {
const pageId = 'b55c9c91-384d-452b-81db-d1ef79372b75';
const response = await notion.pages.retrieve({ page_id: pageId });
console.log(response);
})();
Run Code Online (Sandbox Code Playgroud)
我在用 "@notionhq/client": …
我目前正在尝试非正式地连接到 Notion 主页来上传图像。使用非正式 API 的原因是它不允许我们从本地文件夹上传图像。
话虽如此,我使用 token_v2 成功连接到我的主页,并使用Children.add_new('image')创建了一个图像块。然而,当我尝试上传图像时,遇到了 403 客户端错误。
几天来我一直在努力解决这个问题,所以如果我遗漏了什么,请告诉我。下面是我的代码。
from notion.client import NotionClient
def uploadEvaluationJPG():
token_v2 = secret.notion_API("token_v2")
client = NotionClient(token_v2=token_v2)
# connect page
url = 'https://www.notion.so/Home-******************************'
page = client.get_block(url)
newchild = page.children.add_new('image')
newchild.upload_file(r"C:\NotionUpdate\progress\jpg files\Monthly Evaluation\month.jpg")
newchild.move_to(page.children[1],"before")
page.children[0].remove()
Run Code Online (Sandbox Code Playgroud)
错误代码
Traceback (most recent call last):
Input In [8] in <cell line: 11>
newchild.upload_file(r"C:\NotionUpdate\progress\jpg files\Monthly Evaluation\month.jpg")
File ~\AppData\Roaming\Python\Python39\site-packages\notion\block.py:641 in upload_file
data = self._client.post(
File ~\AppData\Roaming\Python\Python39\site-packages\notion\client.py:265 in post
response.raise_for_status()
File ~\AppData\Roaming\Python\Python39\site-packages\requests\models.py:909 in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 403 Client …Run Code Online (Sandbox Code Playgroud)