notionapi icon indicating copy to clipboard operation
notionapi copied to clipboard

Is SearchFilter necessary?

Open state303 opened this issue 2 years ago • 1 comments

First of all, thank you for the repo! I am very much enjoying it.

Currently, I am testing some workloads with Search.Do function that requires a SearchFilter.

Notion API does not require for us to specify any filter (basically omit,) but I think there must be other reasons you have enforced it not to be nil. However, the objects we retrieve from the Search.Do function do provide the ObjectType, which could hint us the type of the object, meaning that we could possibly skip the SearchFilter if that is nil.

So... if there's any chance, could I post PR with the following and the some tests:

  1. SearchFilter can be nil
  2. Search.Do() will no longer reference nil pointer that were supposed* to be a SearchFilter instance.

But as always, I would like to learn the reason. Thank you!

state303 avatar Sep 24 '23 09:09 state303

I just came across this too. I want to omit the filter to search both page and database objects (which works with the sample curl request in the Notion docs).

But when omitting filter, e.g.

resp, err := client.Search.Do(c.Request().Context(),
	&notionapi.SearchRequest{
		Query: "test",
	})

the API returns the error "body failed validation: body.filter.property should be '\"object\"', instead was '\"\"'." because the request is sent with the body "{\"query\":\"test\",\"filter\":{\"value\":\"\",\"property\":\"\"}}"

mttschltz avatar Mar 30 '24 09:03 mttschltz