Closed kennychan07811 closed 1 year ago
I see, there's a bug. I'll fix it. Thanks for raising
@kennychan07811 please update to latest version and retry, I have a fix for that https://github.com/Vaayne/NotionAI/commit/734b331b38c3a4dc191bf601ffeb3163dc395113
i have the error
def get_spaces(cls, token: str) -> list[dict]: TypeError: 'type' object is not subscriptable
@kennychan07811 could you try this python script, and check the full result
import os
import requests
TOKEN = os.getenv("NOTION_TOKEN")
def main():
url = "https://www.notion.so/api/v3/getSpaces"
headers = {
"accept": "application/json",
"Cookie": "; ".join(["token_v2=" + TOKEN]),
"Content-Type": "application/json",
}
r = requests.post(url, headers=headers)
if r.status_code != 200:
raise ValueError("Cannot get spaces")
res = r.json()
print(res)
spaces = []
for _, val in res.items():
space = val.get("space")
if space:
for k, v in space.items():
space_id = k
space_name = v["value"]["name"]
spaces.append({"id": space_id, "name": space_name})
return spaces
if __name__ == "__main__":
res = print(main())
"Cookie": "; ".join(["token_v2=" + TOKEN]),
TypeError: can only concatenate str (not "NoneType") to str
It seems that you have not set the TOKEN
environment variable correctly. You can replace this with a hard-coded string instead.
TypeError: _build_headers() missing 1 required positional argument: 'token'