Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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β€Ž

Lines changed: 1 addition & 1 deletion
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β€Ž

Lines changed: 1 addition & 1 deletion
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β€Ž

Lines changed: 52 additions & 0 deletions
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)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /