From f3cac7362271bc12a52e0147704f814947e80d08 Mon Sep 17 00:00:00 2001 From: cyrill Date: Mon, 11 Dec 2023 19:45:36 +0500 Subject: [PATCH] fix(close_tasks): improper endpoints and data structure manipulation --- resolved_task.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/resolved_task.py b/resolved_task.py index a0252ce..a8df0fa 100644 --- a/resolved_task.py +++ b/resolved_task.py @@ -45,15 +45,20 @@ def close_tasks_in_queue(queue_name): if response.status_code == 200: logger.debug('Response: %s', response.content) - tasks = response.json().get('status', []) + + tasks = response.json() + for task in tasks: - task_id = task['issue-id'] + task_id = task['id'] close_payload = { - 'status': 'resolved', # Установка статуса "Закрыт" - # 'comment': 'Задача была создана в тестовом режиме' + #'status': 'resolved', # Установка статуса "Закрыт" + #'comment': 'Задача была создана в тестовом режиме' + 'resolution': 'fixed' } - close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}' - close_response = requests.patch( + close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}/transitions/close/_execute' + print(close_url) + print(headers) + close_response = requests.post( close_url, headers=headers, data=json.dumps(close_payload)