create_taiga_task.py 1.2 KB

12345678910111213141516171819
  1. import requests, urllib3
  2. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  3. base_url = 'https://192.168.130.161/taiga/api/v1'
  4. auth = requests.post(f'{base_url}/auth', json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'}, verify=False).json()
  5. headers = {'Authorization': f'Bearer {auth["auth_token"]}', 'Content-Type': 'application/json'}
  6. proj_id = 21
  7. milestones = requests.get(f'{base_url}/milestones?project={proj_id}', headers=headers, verify=False).json()
  8. sprint8 = next((m for m in milestones if m['name'] == 'Sprint 8'), None)
  9. sprint_id = sprint8['id'] if sprint8 else None
  10. payload = {"project": proj_id, "subject": "Deep System Overhaul Phase 3", "description": "Fix Clinical Search Crash, Plate Builder UI, and AI Meal Planner JSON parsing.", "milestone": sprint_id}
  11. res = requests.post(f'{base_url}/userstories', json=payload, headers=headers, verify=False).json()
  12. us_id = res['id']
  13. print(f"Created US: TG-{res['ref']}")
  14. t_payload = {"project": proj_id, "subject": "Execute Phase 3 Overhaul", "user_story": us_id, "milestone": sprint_id}
  15. t_res = requests.post(f'{base_url}/tasks', json=t_payload, headers=headers, verify=False).json()
  16. print(f"Created Task: TG-{t_res['ref']}")