diff --git a/service_desk/handlers.py b/service_desk/handlers.py index 3ffb71e..76c0ae1 100644 --- a/service_desk/handlers.py +++ b/service_desk/handlers.py @@ -69,7 +69,7 @@ sd_sessions = {} async def get_sd_templates(): url = f"{SD_URL}/api/v3/request_templates" - headers = {"authtoken": SD_TOKEN, "Accept": "application/vnd.manageengine.sdp.v3+json"} + headers = {"authtoken": SD_TOKEN, "Accept": "application/vnd.manageengine.sdp.v3+json", "Content-Type": "application/json"} input_data = {"list_info": {"row_count": 100, "start_index": 1}} params = {"input_data": json.dumps(input_data)} try: @@ -170,7 +170,7 @@ async def generate_smart_subject(text: str) -> str: return "Заявка из КЛЕВЕР" async def create_ticket_in_sd(requester_email: str, subject: str, description: str, city: str, template_id: str = None): - headers = {"authtoken": SD_TOKEN, "Accept": "application/vnd.manageengine.sdp.v3+json"} + headers = {"authtoken": SD_TOKEN, "Accept": "application/vnd.manageengine.sdp.v3+json", "Content-Type": "application/json"} endpoint = f"{SD_URL}/api/v3/requests" html_desc = f"
{description.replace(chr(10), '
')}
Создано через TrueConf КЛЕВЕР
" async def _send_req(email, current_city): @@ -178,7 +178,7 @@ async def create_ticket_in_sd(requester_email: str, subject: str, description: s if template_id: req_payload["request"]["request_template"] = {"id": template_id} async with httpx.AsyncClient(verify=False) as client: - resp = await client.post(endpoint, headers=headers, content=json.dumps({"input_data": json.dumps(req_payload)}), timeout=15.0) + resp = await client.post(endpoint, headers=headers, content=json.dumps({"input_data": req_payload}), timeout=15.0) if resp.status_code not in [200, 201]: sd_workflow_logger.error(f"API Error: status={resp.status_code} body={resp.text}") return resp