Mr-Help commited on
Commit
e3504a4
·
verified ·
1 Parent(s): aefcfc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -157,6 +157,27 @@ async def create_task(request: Request):
157
  new_task = response.json()
158
  new_task_id = new_task.get("id")
159
  print("✅ Task created from template:", new_task_id)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
  # Update custom field (used as description)
162
  update_field_url = f"{CLICKUP_URL_BASE}/task/{new_task_id}/field/{custom_field_id}?custom_task_ids=true&team_id={team_id}"
 
157
  new_task = response.json()
158
  new_task_id = new_task.get("id")
159
  print("✅ Task created from template:", new_task_id)
160
+
161
+ # ➕ Prepare the update payload to add the assignee and duedate to the created task from template
162
+ update_payload = {
163
+ "assignees": [int(uid) for uid in assignee_ids],
164
+ "status": status
165
+ }
166
+
167
+ # ➕ Add due date if provided
168
+ if deadline:
169
+ try:
170
+ due_timestamp = int(datetime.strptime(deadline, "%Y-%m-%d").timestamp() * 1000)
171
+ update_payload["due_date"] = due_timestamp
172
+ print(f"📅 Due Date (timestamp): {due_timestamp}")
173
+ except ValueError:
174
+ print("❌ Invalid deadline format. Skipping due_date.")
175
+
176
+ # 🔁 Update the task with assignees and due date
177
+ update_url = f"{CLICKUP_URL_BASE}/task/{new_task_id}"
178
+ update_response = requests.put(update_url, headers=headers, json=update_payload)
179
+ print("🔧 Update Status:", update_response.status_code)
180
+ print("🧾 Update Response:", update_response.text)
181
 
182
  # Update custom field (used as description)
183
  update_field_url = f"{CLICKUP_URL_BASE}/task/{new_task_id}/field/{custom_field_id}?custom_task_ids=true&team_id={team_id}"