test_task.py 834 B

123456789101112131415161718
  1. import requests
  2. import urllib3
  3. urllib3.disable_warnings()
  4. auth = requests.post('https://192.168.130.161/taiga/api/v1/auth', json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'your_db_password_here'}, verify=False).json()
  5. h = {'Authorization': f'Bearer {auth["auth_token"]}'}
  6. # Let's get the list of tasks to see a valid ID
  7. tasks = requests.get('https://192.168.130.161/taiga/api/v1/tasks?project=21', headers=h, verify=False).json()
  8. if tasks:
  9. task_id = tasks[0]['id']
  10. task_ref = tasks[0]['ref']
  11. print(f"Task ID: {task_id}, Ref: {task_ref}")
  12. # Get details
  13. detail = requests.get(f'https://192.168.130.161/taiga/api/v1/tasks/{task_id}', headers=h, verify=False).json()
  14. print("Description in list:", tasks[0].get('description'))
  15. print("Description in detail:", detail.get('description'))