Mr-Help commited on
Commit
14e5b99
·
verified ·
1 Parent(s): 9db62c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -90,17 +90,24 @@ def create_task(task: TaskData):
90
 
91
  # Function to get task name by task ID
92
  def get_task_name(task_id):
93
- url = f"https://api.clickup.com/api/v2/task/{task_id}" # Replace with actual ClickUp API URL
94
- headers = {"Authorization": "Bearer ACCESS_TOKEN"}
95
-
96
- response = requests.get(url, headers=headers)
 
97
 
 
 
 
 
98
  if response.status_code == 200:
99
- task_data = response.json()
100
- return task_data.get("name", "Unknown Task")
 
 
101
  else:
102
- logging.error(f"Failed to fetch task name for {task_id}: {response.text}")
103
- return "Unknown Task"
104
 
105
  @app.post("/updates")
106
  async def task_update(request: Request):
 
90
 
91
  # Function to get task name by task ID
92
  def get_task_name(task_id):
93
+ """Fetch task details from ClickUp API using task_id."""
94
+ url = f"https://api.clickup.com/api/v2/task/{task_id}"
95
+ headers = {
96
+ "Authorization": ACCESS_TOKEN
97
+ }
98
 
99
+ # Make the API request to ClickUp
100
+ response = requests.get(url, headers=headers)
101
+
102
+ # Check if the request was successful (status code 200)
103
  if response.status_code == 200:
104
+ # Parse and return the task details
105
+
106
+ task_name = response.json()["name"]
107
+ return task_name
108
  else:
109
+ task_name = "Task name wasn't not found"
110
+ return task_name
111
 
112
  @app.post("/updates")
113
  async def task_update(request: Request):