fix: добавить Content-Type: application/json и исправить input_data
This commit is contained in:
@@ -69,7 +69,7 @@ sd_sessions = {}
|
|||||||
|
|
||||||
async def get_sd_templates():
|
async def get_sd_templates():
|
||||||
url = f"{SD_URL}/api/v3/request_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}}
|
input_data = {"list_info": {"row_count": 100, "start_index": 1}}
|
||||||
params = {"input_data": json.dumps(input_data)}
|
params = {"input_data": json.dumps(input_data)}
|
||||||
try:
|
try:
|
||||||
@@ -170,7 +170,7 @@ async def generate_smart_subject(text: str) -> str:
|
|||||||
return "Заявка из КЛЕВЕР"
|
return "Заявка из КЛЕВЕР"
|
||||||
|
|
||||||
async def create_ticket_in_sd(requester_email: str, subject: str, description: str, city: str, template_id: str = None):
|
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"
|
endpoint = f"{SD_URL}/api/v3/requests"
|
||||||
html_desc = f"<p>{description.replace(chr(10), '<br>')}</p><br><hr><p style='color:#555;font-size:12px;'><i>Создано через TrueConf КЛЕВЕР</i></p>"
|
html_desc = f"<p>{description.replace(chr(10), '<br>')}</p><br><hr><p style='color:#555;font-size:12px;'><i>Создано через TrueConf КЛЕВЕР</i></p>"
|
||||||
async def _send_req(email, current_city):
|
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:
|
if template_id:
|
||||||
req_payload["request"]["request_template"] = {"id": template_id}
|
req_payload["request"]["request_template"] = {"id": template_id}
|
||||||
async with httpx.AsyncClient(verify=False) as client:
|
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]:
|
if resp.status_code not in [200, 201]:
|
||||||
sd_workflow_logger.error(f"API Error: status={resp.status_code} body={resp.text}")
|
sd_workflow_logger.error(f"API Error: status={resp.status_code} body={resp.text}")
|
||||||
return resp
|
return resp
|
||||||
|
|||||||
Reference in New Issue
Block a user