vzhd1701 / csv2notion

Import/Merge CSV files into Notion database
MIT License
74 stars 10 forks source link

Unsaved transactions: User does not have edit access to record #22

Open jgnunes opened 1 year ago

jgnunes commented 1 year ago

csv2notion version

csv2notion 0.3.7

What OS are you using?

Linux

OS Version / Linux distribution

Ubuntu 22.04.1 LTS

Bug description

Hi, I'm trying to create a database from a CSV file with the following command:

csv2notion --token $notion_token --column-types "text,text,text,text,text,text,text,text,number,number,text,text,text,text,text,text,text,text,text,number,date,number,number,number,number,number,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text" $csv_file

But I'm facing the error:

requests.exceptions.HTTPError: Unsaved transactions: User does not have edit access to record

Although it clearly shows me that my user does not have permission to proceed, I'm not sure what I should do to overcome it.

Any thoughts on how to proceed? Thanks in advance :)

PS1: I've copied $notion_token following the suggested tutorial: https://vzhd1701.notion.site/Find-Your-Notion-Token-5f57951434c1414d84ac72f88226eede

PS2: Removing --column-types "text,text,text,text,text,text,text,text,number,number,text,text,text,text,text,text,text,text,text,number,date,number,number,number,number,number,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text" to simplify the command does not make any difference, still having the same error.

Log excerpt

INFO: Validating CSV & Notion DB schema
INFO: Creating new database
ERROR: Got 400 error attempting to POST to submitTransaction, with data: {
  "operations": [
    {
      "id": "f89ea9df-5bb8-4bf8-b0dd-f3d46b9ffd98",
      "path": [],
      "args": {
        "id": "f89ea9df-5bb8-4bf8-b0dd-f3d46b9ffd98",
        "version": 1,
        "alive": true,
        "created_by_id": "f45d138d-e616-4ea8-839e-b2416b55be67",
        "created_by_table": "notion_user",
        "created_time": 1676905261745,
        "parent_id": "f404e73e-8425-4264-9e99-236bbfc6e4d4",
        "parent_table": "space",
        "space_id": "f404e73e-8425-4264-9e99-236bbfc6e4d4",
        "type": "collection_view_page",
        "permissions": [
          {
            "role": "editor",
            "type": "user_permission",
            "user_id": "f45d138d-e616-4ea8-839e-b2416b55be67"
          }
        ]
      },
      "command": "set",
      "table": "block"
    },
    {
      "args": {
        "last_edited_by_id": "f45d138d-e616-4ea8-839e-b2416b55be67",
        "last_edited_by_table": "notion_user",
        "last_edited_time": 1676905261745
      },
      "command": "update",
      "id": "f89ea9df-5bb8-4bf8-b0dd-f3d46b9ffd98",
      "path": [],
      "table": "block"
    },
    {
      "id": "f404e73e-8425-4264-9e99-236bbfc6e4d4",
      "path": [
        "pages"
      ],
      "args": {
        "id": "f89ea9df-5bb8-4bf8-b0dd-f3d46b9ffd98"
      },
      "command": "listAfter",
      "table": "space"
    },
    {
      "args": {
        "last_edited_by_id": "f45d138d-e616-4ea8-839e-b2416b55be67",
        "last_edited_by_table": "notion_user",
        "last_edited_time": 1676905261745
      },
      "command": "update",
      "id": "f89ea9df-5bb8-4bf8-b0dd-f3d46b9ffd98",
      "path": [],
      "table": "block"
    }
  ]
}
Traceback (most recent call last):
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/bin/csv2notion", line 8, in <module>
    sys.exit(main())
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/csv2notion/cli.py", line 82, in main
    cli(*sys.argv[1:])
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/csv2notion/cli.py", line 39, in cli
    collection_id = new_database(args, client, csv_data)
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/csv2notion/cli_steps.py", line 33, in new_database
    url, collection_id = notion_db_from_csv(
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/csv2notion/notion_db.py", line 142, in notion_db_from_csv
    page_id = client.create_record(
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/notion/client.py", line 417, in create_record
    with self.as_atomic_transaction():
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/notion/client.py", line 469, in __exit__
    self.client.submit_transaction(operations)
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/notion/client.py", line 323, in submit_transaction
    self.post("submitTransaction", data)
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/ratelimit/decorators.py", line 113, in wrapper
    return func(*args, **kargs)
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/ratelimit/decorators.py", line 80, in wrapper
    return func(*args, **kargs)
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/notion/client.py", line 275, in post
    return self._post(endpoint, data)
  File "/home/joaoferreira/miniconda3/envs/csv2notion_env/lib/python3.10/site-packages/notion/client.py", line 290, in _post
    raise HTTPError(
requests.exceptions.HTTPError: Unsaved transactions: User does not have edit access to record