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

httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.notion.com/v1/pages' #13

Closed
believeinb opened this issue Apr 3, 2023 · 4 comments · Fixed by #14

Comments

@believeinb
Copy link

:(

@pulyankote
Copy link

I get the same error as well :(

./gkeep2notion.py
Loading access token from keyring
Authorization, this may take a while...
Logging into Notion
Traceback (most recent call last):
File "xxxxx/notion_client/client.py", line 116, in _parse_response
response.raise_for_status()
File "xxxxxxx/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/pages'
For more information check: https://httpstatuses.com/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "xxxxx/./gkeep2notion.py", line 372, in
create_page(notion, notes)
File "xxxxx/./gkeep2notion.py", line 168, in create_page
notion_page = notion.pages.create(parent=page.parent,
File "xxxxx/notion_client/api_endpoints.py", line 197, in create
return self.parent.request(
File "xxxxx/notion_client/client.py", line 192, in request
return self._parse_response(response)
File "xxxxx/notion_client/client.py", line 124, in _parse_response
raise APIResponseError(response, body["message"], code)
notion_client.errors.APIResponseError: body failed validation. Fix one:
body.parent.database_id should be defined, instead was undefined.
body.parent.page_id should be a valid uuid, instead was "".

@believeinb
Copy link
Author

The error message suggests that there was an issue with the request sent to Notion's API. A 400 Bad Request error usually indicates that the client (in this case, the script) has provided incorrect or malformed data in the request.

In the script, one possible reason for this error is that the root_url in the config file might be incorrect or improperly formatted. The root_url should be a valid Notion URL of the page where you want the imported Google Keep notes and todo lists to be placed.

To fix the issue, double-check the config.ini file and ensure that the root_url under the [notion] section is a valid Notion URL. If you have made changes to the config file, save it and re-run the script.

@Memorix101
Copy link

Yup. I got the same issue 😕

Logging into Notion
Traceback (most recent call last):
  File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\notion_client\client.py", line 116, in _parse_response
    response.raise_for_status()
  File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\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/pages'
For more information check: https://httpstatuses.com/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xxxxxx\Downloads\gkeep2notion-main\gkeep2notion.py", line 372, in <module>
    create_page(notion, notes)
  File "C:\Users\xxxxxx\Downloads\gkeep2notion-main\gkeep2notion.py", line 168, in create_page
    notion_page = notion.pages.create(parent=page.parent,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\notion_client\api_endpoints.py", line 197, in create
    return self.parent.request(
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\notion_client\client.py", line 192, in request
    return self._parse_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\notion_client\client.py", line 124, in _parse_response
    raise APIResponseError(response, body["message"], code)
notion_client.errors.APIResponseError: body failed validation. Fix one:
body.parent.database_id should be defined, instead was `undefined`.
body.parent.page_id should be a valid uuid, instead was `""`.

@nemoitis
Copy link
Contributor

nemoitis commented May 5, 2023

I guess I found the issue. I don't know if this is a new system or not, I couldn't share the Page to my Integration, searching didn't show anything in share menu. After going through notion documentation, I found you have to add connection (integration) to the page like this:

image

Then copy the sharable link and put it in the config.ini file as instructed in readme. Make sure there are no quotations. This worked for me and I guess it will solve the issue here as well.

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

Successfully merging a pull request may close this issue.

4 participants