Skip to content

Commit bc97ff5

Browse files
Merge pull request #179 from notion-dotnet/bfix/178-cannot-insert-page-with-select-property
Fix: Cannot insert page with select property 🐛
2 parents 4605da3 + 0528f7d commit bc97ff5

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

Src/Notion.Client/Models/Database/Properties/SelectProperty.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class SelectOption
3636
/// </summary>
3737
[JsonProperty("color")]
3838
[JsonConverter(typeof(StringEnumConverter))]
39-
public Color Color { get; set; }
39+
public Color? Color { get; set; }
4040
}
4141

4242
public enum Color

Src/Notion.Client/Notion.Client.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>2.0.1-preview</VersionPrefix>
4+
<VersionPrefix>2.2.1-preview</VersionPrefix>
55
<TargetFramework>netstandard2.0</TargetFramework>
66
<LangVersion>7.3</LangVersion>
77

Test/Notion.IntegrationTests/IPageClientTests.cs

+52
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,57 @@ public async Task CreateAsync_CreatesANewPage()
5454
Archived = true
5555
});
5656
}
57+
58+
[Fact]
59+
public async Task Bug_unable_to_create_page_with_select_property()
60+
{
61+
var options = new ClientOptions
62+
{
63+
AuthToken = Environment.GetEnvironmentVariable("NOTION_AUTH_TOKEN")
64+
};
65+
66+
INotionClient _client = new NotionClient(options);
67+
68+
PagesCreateParameters pagesCreateParameters = PagesCreateParametersBuilder.Create(new DatabaseParentInput
69+
{
70+
DatabaseId = "f86f2262-0751-40f2-8f63-e3f7a3c39fcb"
71+
})
72+
.AddProperty("Name", new TitlePropertyValue
73+
{
74+
Title = new List<RichTextBase>
75+
{
76+
new RichTextText
77+
{
78+
Text = new Text
79+
{
80+
Content = "Test Page Title"
81+
}
82+
}
83+
}
84+
})
85+
.AddProperty("TestSelect", new SelectPropertyValue
86+
{
87+
Select = new SelectOption
88+
{
89+
Id = "dfbfbe65-6f67-4876-9f75-699124334d06"
90+
}
91+
})
92+
.Build();
93+
94+
var page = await _client.Pages.CreateAsync(pagesCreateParameters);
95+
96+
page.Should().NotBeNull();
97+
page.Parent.Should().BeOfType<DatabaseParent>().Which
98+
.DatabaseId.Should().Be("f86f2262-0751-40f2-8f63-e3f7a3c39fcb");
99+
100+
page.Properties.Should().ContainKey("Name");
101+
page.Properties["Name"].Should().BeOfType<TitlePropertyValue>().Which
102+
.Title.First().PlainText.Should().Be("Test Page Title");
103+
104+
await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters
105+
{
106+
Archived = true
107+
});
108+
}
57109
}
58110
}

0 commit comments

Comments
 (0)