thomashirtz/notion-clear-trash

Fail to work at Notion 2.30.23.12.0.134

Apolsus opened this issue · 5 comments

Running the script will get an HTTP post error.

image

I am trying to find the source of this API error but no luck so far

This is caused by a change in the POST request field, which was mentioned in the upstream repository.

Can you link me the message containing the POST request that should work ? I tried many time to tune the request and I couldn't find a working payload.

Sorry I'm not available, you can modify your py file directly.

def get_trashed_block_id_list(client: NotionClient, space_id: str) -> List[str]:
    """Function that retrieve a list of `block_id` in the trash of a specific
    `space_id` using a Notion Client.

    Args:
        client: Notion client.
        space_id: Space id.

    Returns:
        List of block_id that are in the trash.
    """
    query = {
        'type': 'BlocksInSpace',
        'query': '',
        'filters': {
            'isDeletedOnly': True,
            'excludeTemplates': False,
            'isNavigableOnly': True,
            'requireEditPermissions': False,
            'ancestors': [],
            'createdBy': [],
            'editedBy': [],
            'lastEditedTime': {},
            'createdTime': {},
            'inTeams': [],
            'includePublicPagesWithoutExplicitAccess': False,
            'navigableBlockContentOnly': True
        },
        'sort': {
            'field': 'lastEdited',
            'direction': 'desc'
        },
        'limit': 1000,
        'spaceId': space_id,
        'source': 'trash',
    }
    results = client.post(endpoint='/api/v3/search', data=query)
    block_list = results.json()['results']
    return [block_id['id'] for block_id in block_list]

It works ! Thank you very much