Notion API master series 17 - Analysis - Append block children

소찬 (Chan)·2022년 10월 31일
0
post-thumbnail

Reference API URL : Append block children

block doesn't support 'create' but available append. Python user is a familiar word about append. It is a method for adding value to a list.
Moreover, append in API means adding block more.

  • block_id (string) required
    Identifier for a block
    Write the page_id for adding blocks in the block_id parameter.

  • children (array) required
    Child content to append to a container block as an array of block objects
    Fill in block information in children. Note children should be array, that is, list form.

children_block_a = {'heading_2': 
                      {'rich_text': 
                         [
                            {'text': {'content': '추가 메뉴'}}
                         ]
                      }
                   }

children_block_b = {'heading_3': 
                      {'rich_text': 
                         [
                            {'text': {'content': '타바스코 핫소스'}}
                         ]
                      }
                   }

Children are a form of an array, so let's bind as an array.

children_blocks = []
children_blocks.append(children_block_a)
children_blocks.append(children_block_b)

Now try to update with the bound array.
Put page_id into block_id and list, which is block bunches into children and call the API.

notion.blocks.children.append(block_id=page_id, children=children_blocks)

Like below, API added two blocks.

profile
QA Specialist

0개의 댓글