Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search request always return an empty results

Tags:

notion-api

I'm trying to search into my workspace to find a page with the mention "Nora" inside the title. Here is the Python code I'm working with:

data = {
    'query': 'Nora',
    'page_size': 10
}

r = requests.post('https://api.notion.com/v1/search', headers={
    'Authorization': f"Bearer {token}",
    'Content-Type': 'application/json',
    'Notion-Version': "2022-02-22"
}, data=json.dumps(data))

result = r.json()
print(result)

The content of result is as follow:

{
    'object': 'list', 
    'results': [], 
    'next_cursor': None, 
    'has_more': False, 
    'type': 'page_or_database', 
    'page_or_database': {}
}

Same thing when I try with cURL:

curl -X POST 'https://api.notion.com/v1/search' -H 'Authorization: Bearer blablabla' \
        -H 'Content-Type: application/json' \
        -H 'Notion-Version: 2022-02-22' \
        --data '{"query": "Nora", "page_size": 10}'

Of course the Bearer is not blablabla, and I double checked if I was in the right workspace (which I am). My query doesn't have the \ (all in one line, only added the slashes for reading).

Is there something else I should do?

like image 603
Havarem Avatar asked Feb 03 '26 11:02

Havarem


1 Answers

I found the solution. It appears that now you need to "share" the pages you want to access to your integration beforehand. I don't know if it solves your problem Genaro Alberto Cancino Herrera, maybe they change their API recently and added that feature.

like image 128
Havarem Avatar answered Feb 06 '26 06:02

Havarem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!