Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching does not work #555

Closed
nynevi opened this issue Jun 27, 2024 · 1 comment
Closed

Searching does not work #555

nynevi opened this issue Jun 27, 2024 · 1 comment

Comments

@nynevi
Copy link

nynevi commented Jun 27, 2024

Discovered while working on transitive-bullshit/nextjs-notion-starter-kit#618

The line here https://github.com/NotionX/react-notion-x/blob/master/packages/notion-client/src/notion-api.ts#L606
makes the below request:

curl --location 'https://www.notion.so/api/v3/search' \
--header 'Content-Type: application/json' \
--header 'Cookie: __cf_bm=l9fYQeZBInjE_IYkZfI39Rl84cClfIeJ9kCFQsKLGpc-1719470820-1.0.1.1-qFgBx5G_xqV_lkEMjjrVP5CSifPI.ZZ5vTvMbItNYy0tlItIWVr46e_2qYJYcXpmkS7OvvPlmWZCcr_ttBADkw; _cfuvid=T0dzvs1rxC8sFknZk47Efnx912M1XYiciVUPvyZ8S8A-1719470820038-0.0.1.1-604800000; device_id=6513a169-b1fc-404a-9ce8-3d4f6e450778; notion_browser_id=5d90bc05-2cad-4554-b6c5-f9bb2da47c67; notion_check_cookie_consent=false' \
--data '{
    "type": "BlocksInAncestor",
    "source": "quick_find_public",
    "ancestorId": "0191bcee-9db0-4c36-90b8-4062af8f12e2",
    "sort": "Relevance",
    "limit": 20,
    "query": "",
    "filters": {
        "isDeletedOnly": false,
        "isNavigableOnly": false,
        "excludeTemplates": true,
        "requireEditPermissions": false,
        "ancestors": [],
        "createdBy": [],
        "editedBy": [],
        "lastEditedTime": {},
        "createdTime": {}
    }
}'

and gets:

{
    "errorId": "519936dd-0928-445f-8a4f-f223acef4a89",
    "name": "ValidationError",
    "debugMessage": "Invalid input.",
    "message": "Something went wrong. (400)"
}

Notion endpoint https://www.notion.so/api/v3/search does not seem to be publicly documented.
I reversed engineer on Notion site by checking what might be considered as an invalid input. The culprit seems to be:
"sort": "Relevance" versus

"sort": {
    "field": "relevance"
}, 
@nynevi
Copy link
Author

nynevi commented Jun 27, 2024

my bad, the starter kit seems to use an old version of this package. here the query is actually fixed https://github.com/NotionX/react-notion-x/blob/master/packages/notion-client/src/notion-api.ts#L552

@nynevi nynevi closed this as completed Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant