dstotijn / go-notion

Go client for the Notion API.
MIT License
380 stars 39 forks source link

Encountering Error Code 500 on Database Query #2

Closed max-legrand closed 3 years ago

max-legrand commented 3 years ago

When the following line executes, it returns back stating an error with code 500 occurs.

response, err := client.QueryDatabase(context.Background(), id, query)

I'm not particularly sure where the issue is arising, so any help resolving is appreciated!

dstotijn commented 3 years ago

Hi! Could you share what your query value looks like?

max-legrand commented 3 years ago

Yep!

image

I also tried with a blank query and that also kicked back with the same error. For reference, when I just use standard POST requests it seems to work (e.g. via Postman generated Go code)

Also this is the contents of truePointer:

image
dstotijn commented 3 years ago

Thanks for the detailed feedback! There was a bug where the various search filter fields were not being omitted from JSON, because they were struct values instead of struct pointers. Fixed in v0.1.1. Note: The fix is a breaking change; you'll have to update your code, e.g. to this:

query := notion.DatabaseQuery{
    Filter: notion.DatabaseQueryFilter{
        And: []notion.DatabaseQueryFilter{
            {
                Property: "Done",
                Checkbox: &notion.CheckboxDatabaseQueryFilter{
                    Equals: notion.BoolPtr(true),
                },
            },
            {
                Property: "Repeat",
                Select: &notion.SelectDatabaseQueryFilter{
                    IsNotEmpty: true,
                },
            },
            {
                Property: "Date",
                Date: &notion.DateDatabaseQueryFilter{
                    IsNotEmpty: true,
                },
            },
        },
    },
}
max-legrand commented 3 years ago

Awesome thank you so much for the super fast assistance!