Reputation: 116
Going through the Notion API docs, it mentions the text configuration is same as rich-text-object.
In the response for my page, I view the text property as -
{
"object": "page",
"id": "123",
"created_time": "2021-02-18T15:12:00.000Z",
"last_edited_time": "2021-05-15T12:37:30.830Z",
"parent": {
"type": "database_id",
"database_id": "456"
},
"archived": false,
"properties": {
"Highlights": {
"id": "jCaG",
"type": "text",
"text": [
{
"type": "text",
"text": {
"content": "test 1\ntest 2",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "test 1\ntest 2",
"href": null
}
]
}
}
My question is, if the text
property takes an array, can we add multiple text objects to it?
I tried to do the same with the PATCH
request to the update page record, but the response was not as expected, it switched all the annotations to true
, ie. bold, italic, underline, strike-through and code blocks all were true, even though they weren't in the initial request.
Here, is the JSON I sent in my PATCH
call -
{
"object": "page",
"id": "123",
"created_time": "2021-02-18T15:12:00.000Z",
"last_edited_time": "2021-05-15T12:09:00.000Z",
"parent": {
"type": "database_id",
"database_id": "456"
},
"archived": false,
"properties": {
"Highlights": {
"id": "jCaG",
"type": "text",
"text": [
{
"type": "text",
"text": {
"content": "test 1\ntest 2",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "test 1\ntest 2",
"href": null
},
{
"type": "text",
"text": {
"content": "test 3",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "test 3",
"href": null
}
]
}
}
And the response from the same was -
{
"object": "page",
"id": "123",
"created_time": "2021-02-18T15:12:00.000Z",
"last_edited_time": "2021-05-15T12:37:30.830Z",
"parent": {
"type": "database_id",
"database_id": "456"
},
"archived": false,
"properties": {
"Highlights": {
"id": "jCaG",
"type": "text",
"text": [
{
"type": "text",
"text": {
"content": "test 1\ntest 2",
"link": null
},
"annotations": {
"bold": true,
"italic": true,
"strikethrough": true,
"underline": true,
"code": true,
"color": "default"
},
"plain_text": "test 1\ntest 2",
"href": null
},
{
"type": "text",
"text": {
"content": "test 3",
"link": null
},
"annotations": {
"bold": true,
"italic": true,
"strikethrough": true,
"underline": true,
"code": true,
"color": "default"
},
"plain_text": "test 3",
"href": null
}
]
}
}
Has anyone here experimented with the text property, if yes, can you please guide me through the same?
Thanks.
Upvotes: 2
Views: 2925
Reputation: 4417
Here is a call you can test to play with rich_text. This should work as long as you have your database set-up with a text column called "sample_text". It should work as you would expect.
curl --location --request PATCH 'https://api.notion.com/v1/pages/YOUR_PAGE_ID' \
--header 'Notion-Version: 2021-05-13' \
--header 'Authorization: Bearer YOUR_BOT_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"parent":{
"database_id":"DATABASE_ID"
},
"properties":{
"Name":{
"title":[
{
"text":{
"content":"A Test Page"
}
}
]
},
"sample_text":{
"rich_text":[
{
"type":"text",
"text":{
"content":"Some more text with "
}
},
{
"type":"text",
"text":{
"content":"some"
},
"annotations":{
"italic":true,
"bold": false,
"underline": false,
"strikethrough": true,
"color": "blue"
}
},
{
"type":"text",
"text":{
"content":" "
}
},
{
"type":"text",
"text":{
"content":"fun"
},
"annotations":{
"bold":true,
"underline": false,
"strikethrough": false
}
},
{
"type":"text",
"text":{
"content":" "
}
},
{
"type":"text",
"text":{
"content":"formatting"
},
"annotations":{
"color":"pink"
}
}
]
}
}
}'
Upvotes: 2