Closed Vadim-Borovikov closed 12 months ago
When passing null
, API returns error
Invalid property value for: "Text".
When passing new RichTextPropertyValue()
, API returns error
body failed validation. Fix one: body.properties.Text.title should be defined, instead was
undefined
. body.properties.Text.rich_text should be defined, instead wasundefined
. body.properties.Text.number should be defined, instead wasundefined
. body.properties.Text.url should be defined, instead wasundefined
. body.properties.Text.select should be defined, instead wasundefined
. body.properties.Text.multi_select should be defined, instead wasundefined
. body.properties.Text.people should be defined, instead wasundefined
. body.properties.Text.email should be defined, instead wasundefined
. body.properties.Text.phone_number should be defined, instead wasundefined
. body.properties.Text.date should be defined, instead wasundefined
. body.properties.Text.checkbox should be defined, instead wasundefined
. body.properties.Text.relation should be defined, instead wasundefined
. body.properties.Text.files should be defined, instead wasundefined
. body.properties.Text.status should be defined, instead wasundefined
. body.properties.Text.id should be defined, instead wasundefined
. body.properties.Text.name should be defined, instead wasundefined
. body.properties.Text.start should be defined, instead wasundefined
.
When passing new RichTextPropertyValue { RichText = new List<RichTextBase>() }
, API returns error
body failed validation. Fix one: body.properties.Text.id should be defined, instead was
undefined
. body.properties.Text.name should be defined, instead wasundefined
. body.properties.Text.start should be defined, instead wasundefined
.
Initially, I am able to successfully fill empty Text property with code:
RichTextPropertyValue result = new()
{
RichText = new List<RichTextBase>()
};
Text text = new() { Content = content };
RichTextText item = new() { Text = text };
result.RichText.Add(item);
return result;
But If this property already have some value, I see:
body failed validation. Fix one: body.properties.MyTestField.id should be defined, instead was
undefined
. body.properties.MyTestField.name should be defined, instead wasundefined
. body.properties.MyTestField.start should be defined, instead wasundefined
.
Okay, so my experiments show that it is something with multiple properties at nose.
This works:
public async Task TestAsync(string pageId)
{
await TestUpdate(pageId, null, "https://github.com");
await TestUpdate(pageId, "text 1", null);
await TestUpdate(pageId, null, "https://github.com");
await TestUpdate(pageId, "text 2", null);
await TestUpdate(pageId, null, "https://github.com");
}
private async Task TestUpdate(string pageId, string? text, string? url)
{
Dictionary<string, PropertyValue?> properties = new()
{
{ "Text", CreateTextValue(text) },
};
await _client.Pages.UpdatePropertiesAsync(pageId, properties);
properties = new Dictionary<string, PropertyValue?>
{
{ "URL", url is null ? null : new UrlPropertyValue { Url = url } }
};
await _client.Pages.UpdatePropertiesAsync(pageId, properties);
}
and this produces errors for some reason:
public async Task TestAsync(string pageId)
{
await TestUpdate(pageId, null, "https://github.com");
await TestUpdate(pageId, "text 1", null);
await TestUpdate(pageId, null, "https://github.com");
await TestUpdate(pageId, "text 2", null);
await TestUpdate(pageId, null, "https://github.com");
}
private async Task TestUpdate(string pageId, string? text, string? url)
{
Dictionary<string, PropertyValue?> properties = new()
{
{ "Text", CreateTextValue(text) },
{ "URL", url is null ? null : new UrlPropertyValue { Url = url } }
};
await _client.Pages.UpdatePropertiesAsync(pageId, properties);
}
@Vadim-Borovikov I tried to reproduce this but it seems the problem is with the Notion API. I verified this by directly using Postman. May be you could report this at https://github.com/makenotion/notion-sdk-js
Describe the bug Pages.UpdatePropertiesAsync fails when non-empty Text property gets updated.
To Reproduce Steps to reproduce the behavior:
Expected behavior Properties get updated, no errors from API.