List spaces in a section

This guide explains how to use the list method on the SectionItem resource of the Google Chat API to list items (such as spaces) in a section.

Only spaces can be section items. For more information, see Create and organize sections in Google Chat .

Prerequisites

Python

List spaces in a section

To list spaces in a section with user authentication , pass the following in your request:

  • Specify the chat.users.sections or chat.users.sections.readonly authorization scope.
  • Call the ListSectionItems method.
  • Set parent to the resource name of the section.

The following example lists spaces in a section:

Python

  from 
  
 google.cloud 
  
 import 
 chat_v1 
 def 
  
 list_section_items 
 (): 
 # Create a client 
 client 
 = 
 chat_v1 
 . 
 ChatServiceClient 
 () 
 # Initialize request 
 request 
 = 
 chat_v1 
 . 
 ListSectionItemsRequest 
 ( 
 parent 
 = 
 "SECTION_NAME" 
 ) 
 # Make the request 
 page_result 
 = 
 client 
 . 
 list_section_items 
 ( 
 request 
 = 
 request 
 ) 
 # Handle the response 
 for 
 item 
 in 
 page_result 
 : 
 print 
 ( 
 item 
 ) 
 

To run this sample, replace the following:

  • SECTION_NAME : The resource name of the section. You can obtain the resource name by calling the ListSections method.

The Chat API returns a list of SectionItem resources.

Create a Mobile Website
View Site in Mobile | Classic
Share by: