TheAcharya / csv2notion-neo

Upload & Merge CSV or JSON Data with Images to Notion Database
MIT License
21 stars 1 forks source link

[Bug]: 400 when importing rows with image #32

Closed kreed-gench closed 5 months ago

kreed-gench commented 6 months ago

CSV2Notion Neo Version?

1.2.4

What OS are you using?

Windows

OS Version or Linux distribution

Windows 10

Bug Description

When running: csv2notion_neo --workspace "xx" --image-column "image column" --token "xx" --url "xx" notion_test.csv --verbose --merge

ERROR: Got 400 error attempting to POST to submitTransaction, with data: {
  "operations": [
    {
      "id": "c304b32f-057c-49e1-a150-5205e430d5f1",
      "path": [
        "properties",
        "meta",
        "cover_block"
      ],
      "args": {
        "type": "file",
        "file_id": "92f9bd7c-052d-4375-8d1e-ca905f575105",
        "sha256": "03faf047645c797822ba21674cb3d2bc07cc7b0c822d657dd228207ad6af4cc3"
      },
      "command": "set",
      "table": "block"
    },
    {
      "args": {
        "last_edited_by_id": "602916d9-178b-4654-b39e-9501e4d89219",
        "last_edited_by_table": "notion_user",
        "last_edited_time": 1713646552787
      },
      "command": "update",
      "id": "c304b32f-057c-49e1-a150-5205e430d5f1",
      "path": [],
      "table": "block"
    }
  ]
}

Log excerpt

2024-04-20 16:00:51,983 [INFO    ] CSV2Notion Neo version 1.2.4
2024-04-20 16:00:51,984 [INFO    ] Validating csv & csv2notion_neo.notion DB schema
2024-04-20 16:00:52,513 [INFO    ] Uploading notion_test.csv...
2024-04-20 16:00:56,646 [ERROR   ] Error at division
Traceback (most recent call last):
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\cli.py", line 58, in cli
    upload_rows(
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\cli_steps.py", line 79, in upload_rows
    list(tdqm_iter)
  File "C:\Users\kreed\AppData\Local\Programs\Python\Python310\lib\site-packages\tqdm\std.py", line 1182, in __iter__
    for obj in iterable:
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\utils_threading.py", line 38, in process_iter
    yield from (f.result() for f in as_completed(futures))
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\utils_threading.py", line 38, in <genexpr>
    yield from (f.result() for f in as_completed(futures))
  File "C:\Users\kreed\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 451, in result
    return self.__get_result()
  File "C:\Users\kreed\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\_base.py", line 403, in __get_result
    raise self._exception
  File "C:\Users\kreed\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\utils_threading.py", line 26, in worker
    notion_uploader.upload_row(*args, **kwargs)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion_uploader.py", line 34, in upload_row
    setattr(db_row, prop, prop_val)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion_row.py", line 100, in cover_block
    self.cover_block_meta = cover_block_meta
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion\maps.py", line 50, in fset
    self.set(path, python_to_api(value, **kwargs))
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion\records.py", line 115, in set
    self._client.submit_transaction(
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion\client.py", line 350, in submit_transaction
    self.post("submitTransaction", data)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\ratelimit\decorators.py", line 113, in wrapper
    return func(*args, **kargs)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\ratelimit\decorators.py", line 80, in wrapper
    return func(*args, **kargs)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion\client.py", line 299, in post
    return self._post(endpoint, data)
  File "C:\Users\kreed\AppData\Roaming\Python\Python310\site-packages\csv2notion_neo\notion\client.py", line 316, in _post
    raise HTTPError(
requests.exceptions.HTTPError: Something went wrong. (400)
IAmVigneswaran commented 6 months ago

Thanks for reporting! We are investigating the issue.

kreed-gench commented 6 months ago

👍 I've tested this on both local images and also url path to image but both come up with the same error

IAmVigneswaran commented 6 months ago

👍 I've tested this on both local images and also url path to image but both come up with the same error

The error is due to Notion's recent API changes.

IAmVigneswaran commented 6 months ago

@vzhd1701 Hey Vlad, do you have any insights on how you might fix and address this. Apparently due to recent Notion's API changes, we can't upload CSV/JSON with images. I believe it would be the same for your csv2notion too.

lparolari commented 5 months ago

I am willing to help if you can kindly provide guidance 🙂 I am very new to Notion API although I've been using Notion for a while.

The error is due to Notion's recent API changes.

To which change are you referring to? I've taken a look at https://developers.notion.com/page/changelog and for April 2024 they state: "Endpoint Update: archived to in_trash". Is this the cause of the problem?

IAmVigneswaran commented 5 months ago

@lparolari Thanks for your message!

There are API changes known to public and there are backend API that are not known to public in an official capacity.

This issue is priority. Hopefully we can release a fix soon.

Thanks for your patience.

IAmVigneswaran commented 5 months ago

@kreed-gench @lparolari This issue is now fixed in 1.2.5. You should now be able to upload images.

Thanks.