Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Created March 29, 2022 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuongmep/a9e527b312bc745c7dc1e51876958be6 to your computer and use it in GitHub Desktop.
Save chuongmep/a9e527b312bc745c7dc1e51876958be6 to your computer and use it in GitHub Desktop.
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