Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client error '400 Bad Request' with body.children[0].paragraph.rich_text[16].text.content.length should be ≤ 2000, instead was 2001. #92

Open
kfong257 opened this issue Feb 26, 2023 · 0 comments

Comments

@kfong257
Copy link

Describe the bug
Throwing these two errors:

httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.notion.com/v1/blocks/xxxx/children'
For more information check: https://httpstatuses.com/400

notion_client.errors.APIResponseError: body failed validation: body.children[0].paragraph.rich_text[16].text.content.length should be ≤ 2000, instead was 2001.

Full traceback below:

Traceback (most recent call last):
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/notion_client/client.py", line 118, in _parse_response
response.raise_for_status()
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/httpx/_models.py", line 749, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.notion.com/v1/blocks/xxxx/children'
For more information check: https://httpstatuses.com/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/kf25/Library/Python/3.9/bin/kindle2notion", line 8, in
sys.exit(main())
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/kindle2notion/main.py", line 44, in main
export_to_notion(
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/kindle2notion/exporting.py", line 36, in export_to_notion
message = _add_book_to_notion(
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/kindle2notion/exporting.py", line 159, in _add_book_to_notion
notion.blocks.children.append(page, page_content)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/notional/session.py", line 133, in append
data = self().append(block_id=parent_id, children=children)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/notion_client/api_endpoints.py", line 23, in append
return self.parent.request(
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/notion_client/client.py", line 194, in request
return self._parse_response(response)
File "/Users/kf25/Library/Python/3.9/lib/python/site-packages/notion_client/client.py", line 126, in _parse_response
raise APIResponseError(response, body["message"], code)
notion_client.errors.APIResponseError: body failed validation: body.children[0].paragraph.rich_text[16].text.content.length should be ≤ 2000, instead was 2001.

To Reproduce

  1. Run this this My Clippings.txt upon import (see attached).

Expected behaviour
I think this exception means that the quote is too big for Notion to accept There should be some way to handle the exception, and then an alternative means to get the quote into the block manually (i.e. a separate text file that the user can paste into the database himself.)
My Clippings 3.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant