Created
March 29, 2022 15:56
-
-
Save chuongmep/a9e527b312bc745c7dc1e51876958be6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static async Task Main(string[] args) | |
{ | |
var client = new NotionClient(new ClientOptions | |
{ | |
AuthToken = "secret_d6dNtdaIffTAGhDXRhha4ddsdsy0dAfsr27ct3acszPnNOmGIY" | |
}); | |
var databasesQueryParameters = new DatabasesQueryParameters(); | |
var databaseId = "8a71f62d45aaf24e8dbdsdsd9090f703181e33"; | |
var queryResult = await client.Databases.QueryAsync(databaseId,databasesQueryParameters); | |
Console.WriteLine(queryResult.Results.Count); | |
foreach (var result in queryResult.Results) | |
{ | |
Console.WriteLine("Page Id: " + result.Id); | |
foreach (var property in result.Properties) | |
{ | |
Console.WriteLine(property.Key + " " + GetValue(property.Value)); | |
} | |
} | |
Console.ReadKey(); | |
} | |
static object GetValue(PropertyValue p) | |
{ | |
switch (p) | |
{ | |
case RichTextPropertyValue richTextPropertyValue: | |
return richTextPropertyValue.RichText.FirstOrDefault()?.PlainText; | |
default: | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment