diff --git a/notion_client/api_endpoints.py b/notion_client/api_endpoints.py index fdd4ab1..36a839c 100644 --- a/notion_client/api_endpoints.py +++ b/notion_client/api_endpoints.py @@ -226,10 +226,15 @@ def update(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]: *[🔗 Endpoint documentation](https://developers.notion.com/reference/patch-page)* """ # noqa: E501 + body = pick(kwargs, "archived", "properties", "icon", "cover") + for nullable_attr in ("icon", "cover"): # make sure those are set to `None` + if kwargs.get(nullable_attr, object) is None: + body[nullable_attr] = None + return self.parent.request( path=f"pages/{page_id}", method="PATCH", - body=pick(kwargs, "archived", "properties", "icon", "cover"), + body=body, auth=kwargs.get("auth"), ) diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index bef0872..369331e 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -26,7 +26,11 @@ def test_pages_update(client, page_id): response = client.pages.update(page_id=page_id, icon=icon) assert response["icon"] - + + # delete icon again + response = client.pages.update(page_id=page_id, icon=None) + assert response["icon"] is None + @pytest.mark.vcr() def test_pages_properties_retrieve(client, page_id):