Hey everyone, I’m having trouble with the ‘text’ property in Notion’s API. I’m trying to add multiple text objects to a single property, but it’s not working as expected.
When I send a PATCH request to update a page, the API response shows all text formatting (bold, italic, etc.) set to true, even though I didn’t request this in my original JSON.
Here’s a simplified version of what I’m sending:
{
"properties": {
"MyTextProperty": {
"type": "text",
"text": [
{
"content": "First line\nSecond line",
"annotations": {
"bold": false,
"italic": false
}
},
{
"content": "Third line",
"annotations": {
"bold": false,
"italic": false
}
}
]
}
}
}
But the response comes back with all annotations set to true. Is this a bug, or am I doing something wrong?
Has anyone successfully added multiple text objects to a single property? Any tips or workarounds would be super helpful. Thanks!
hey, i’ve run into this too. it’s super annoying!
what worked for me was using a single text object with line breaks like this:
“content”: “First line\nSecond line\nThird line”
it’s not perfect, but it keeps things simpler. hope this helps!
I’ve encountered similar issues with Notion’s API, particularly when dealing with text properties. From my experience, the behavior you’re describing seems to be a quirk in how Notion handles text formatting in API responses.
One workaround I’ve found effective is to split the content into separate properties instead of trying to add multiple text objects to a single property. This approach has been more reliable for me, though it does require restructuring your data model slightly.
Alternatively, you could try sending the content as a single text object with line breaks (\n) instead of separate objects. This might help preserve the intended formatting:
{
"properties": {
"MyTextProperty": {
"type": "text",
"text": [
{
"content": "First line\nSecond line\nThird line",
"annotations": {
"bold": false,
"italic": false
}
}
]
}
}
}
If these approaches don’t work, you might need to handle the formatting discrepancies on the client-side when reading the API response. It’s not ideal, but it could be a temporary solution while Notion addresses this issue.
I’ve grappled with this issue in my Notion API projects as well. It’s a bit of a headache, especially when you’re trying to maintain specific formatting.
One approach that’s worked for me is to use the ‘rich_text’ property type instead of ‘text’. It offers more granular control over formatting and seems to handle multiple entries more reliably.
Here’s a sample JSON structure I’ve used successfully:
{
\"properties\": {
\"MyTextProperty\": {
\"type\": \"rich_text\",
\"rich_text\": [
{
\"type\": \"text\",
\"text\": { \"content\": \"First line\" },
\"annotations\": { \"bold\": false, \"italic\": false }
},
{
\"type\": \"text\",
\"text\": { \"content\": \"\\nSecond line\" },
\"annotations\": { \"bold\": false, \"italic\": false }
},
{
\"type\": \"text\",
\"text\": { \"content\": \"\\nThird line\" },
\"annotations\": { \"bold\": false, \"italic\": false }
}
]
}
}
}
This method has consistently preserved my intended formatting. It’s a bit more verbose, but it gives you precise control over each line’s annotations. Give it a shot and see if it resolves your formatting issues.