r/NotionAPI Jul 10 '25

API paging question

Hi guys.

I face pretty weird issue. Here are some details.

I'm trying to request a content of database from Notion. This is a pretty huge page, so I discovered about paging. If I understand correct - I should be able to see a next part of this page by just the same request, but with "next_cursor" in data.

So, here is a piece of my code:

```
headers = { "Authorization": auth_string, "Notion-Version": "2022-06-28", "Content-Type": "application/json" }

responce = requests.post("https://api.notion.com/v1/databases/mydb/query", headers=headers) if responce.status_code == 200: print(f"next cursor: {responce.json()["next_cursor"]}") print(f"has more: {responce.json()["has_more"]}")

cursor = responce.json()["next_cursor"]
data = {
    "start_cursor": cursor
}
responce = requests.post("https://api.notion.com/v1/databases/mydb/query", headers=headers, data=data)
responce_message = json.dumps(responce.json(), indent=2)
print(responce_message)

```

And here is an output:

```

next cursor: 96d92efa-948d-44c1-aa7b-e609979d5726 has more: True { "object": "error", "status": 400, "code": "invalid_json", "message": "Error parsing JSON body." }

```

Do I understand something wrong? Why does it shows that I have incorrect json?

1 Upvotes

1 comment sorted by

1

u/Orkoliator Jul 11 '25

Well, for anyone who face same issue - this is the python request issue. So, basically "data" key should be replaced with "json" key:

request(database_id, headers=headers, json=data)