2021年6月1日より「Notion-Version」ヘッダが必要になる

開示?
開示?
原題
"Notion-Version" header will be required starting June 1, 2021
日付
May 20, 2021
Number
5
前のリリース日(最新)
リリース間隔(日)
作成日
Nov 9, 2021 09:31 PM
タグ
経過日数

Notion-Version の必須化

Notion API を使う時には、HTTP request に対して、 Notion-Version ヘッダを付けることを推奨していたが、6月1日以降は必須になった。この記事の時点の最新バージョンは "2021-05-13"だった。私が作ったアプリもまだこのバージョンなので、この記事をまとめながら更新していきたい。
ちなみに、現在ではこのヘッダがないと "missing_version" error が発生するとのこと。Version に関する内容はここから読める。→ handles versioning
If you've been using examples copied from documentation or example code since the public beta, including using the Notion SDK for JavaScript, your existing code should continue to work as expected.

2021-05-13バージョンにおける破壊的変更

この時点での最新バージョンである「2021-05-13」では「2021-05-11」までと違い、以下の破壊的変更が行われた。今後も破壊的な変更がある場合には、こんな感じで明示的にバージョンのアップデートが行われると思う。
このバージョンで変更されたのは、プロパティテキストのオブジェクト名である。これまでは、
"text" だったものが、 "rich_text"に変更されている。私が使い始めた段階ではすでに「2021-05-13」だったので、すでに rich_text だった。

検証

前回と同じで、このページ自身を取得してみる。
#!/bin/sh curl -X POST 'https://api.notion.com/v1/search' \ -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \ -H 'Content-Type: application/json' \ -H "Notion-Version: 2021-08-16" \ --data '{ "query":"Notion-Version", "sort":{ "direction":"ascending", "timestamp":"last_edited_time" } }'
結果はこんな感じ。原題の部分がテキストなどで、その属性が「rich_text」になっていることがわかる。
{ "object": "list", "results": [ { "object": "page", "id": "9b5c3ea9-a8c0-41a8-b5e4-e1e97fad4ddf", "created_time": "2021-11-09T21:31:00.000Z", "last_edited_time": "2021-11-09T23:18:00.000Z", "cover": null, "icon": null, "parent": { "type": "database_id", "database_id": "c63c00ad-201d-4bed-82b0-18dfca9b6ba0" }, "archived": false, "properties": { "日付": { "id": "%3CWbe", "type": "date", "date": { "start": "2021-05-20", "end": null } }, "原題": { "id": "%3FMR%7D", "type": "rich_text", "rich_text": [ { "type": "text", "text": { "content": "\"Notion-Version\" header will be required starting June 1, 2021", "link": null }, "annotations": { "bold": false, "italic": false, "strikethrough": false, "underline": false, "code": false, "color": "default" }, "plain_text": "\"Notion-Version\" header will be required starting June 1, 2021", "href": null } ] }, "URL": { "id": "o%3A~F", "type": "url", "url": "https://developers.notion.com/changelog/unversioned-requests-no-longer-accepted" }, "タグ": { "id": "tUJV", "type": "multi_select", "multi_select": [] }, "名前": { "id": "title", "type": "title", "title": [ { "type": "text", "text": { "content": "2021年6月1日より「Notion-Version」ヘッダが必要になる", "link": null }, "annotations": { "bold": false, "italic": false, "strikethrough": false, "underline": false, "code": false, "color": "default" }, "plain_text": "2021年6月1日より「Notion-Version」ヘッダが必要になる", "href": null } ] } }, "url": "https://www.notion.so/2021-6-1-Notion-Version-9b5c3ea9a8c041a8b5e4e1e97fad4ddf" } ], "next_cursor": null, "has_more": false }

🖇️
Notion API Changelog まとめ