Список всех папок из пространства ClickUpPython

Программы на Python
Anonymous
Список всех папок из пространства ClickUp

Сообщение Anonymous »

Я пытаюсь перечислить все папки, созданные в определенном пространстве ClickUp, но это не дает желаемого результата. Ниже приведен фрагмент:

Код: Выделить всё

import requests

# Enter your ClickUp API token here
api_token = 'pk_xxxxxxxxxxx'

# Space ID for the desired space
space_id = '1234567'

# API endpoint for retrieving folders in a space
folders_url = f'https://api.clickup.com/api/v2/space/{space_id}/folder'

# Headers with authorization
headers = {
'Authorization': api_token,
'Content-Type': 'application/json'
}

def list_all_folders():
try:
# Send GET request to retrieve folders in the space
response = requests.get(folders_url, headers=headers)
response.raise_for_status()  # Raise exception if request fails

# Parse the JSON response
folders_data = response.json()

# Extract and print folder details
for folder in folders_data['folders']:
folder_id = folder['id']
folder_name = folder['name']
print(f"Folder ID: {folder_id}, Folder Name: {folder_name}")

except requests.exceptions.HTTPError as err:
print(f"Error: {err}")

# Call the function to list all folders in the space
list_all_folders()
Хотя я передал правильный токен, при выполнении этого кода я получаю эту ошибку:

Ошибка: 401 Ошибка клиента: Не авторизован для URL:
https://api.clickup.com/api/v2/space/1234567/folder


Подробнее здесь: https://stackoverflow.com/questions/763 ... ckup-space

Вернуться в «Python»