import requests
def create_incident(title, description, priority, catalog_item_id, category, subcategory):
incident_data = {
"incident": {
"name": title,
"description": description,
"priority": priority,
"catalog_item_id": catalog_item_id,
"Employee name": Employee_Email,
"Subsidiary": Subsidiary,
"category": {
"name": category
},
"subcategory": {
"name": subcategory
},
}
}
# Make API request to create incident
headers = {
'X-Samanage-Authorization': 'Bearer xxxx’
'Content-Type': 'application/json'
}
create_incident_url = 'api.samanage.com/incidents.json'
print("Incident Data Sent:")
print(incident_data) # Print the incident data being sent
response = requests.post(create_incident_url, headers=headers, json=incident_data)
# Print API response for debugging
print("API Response:")
print(response.text) # Print the API response text
# Handle response status
if response.status_code == 201:
# Extract and print incident number if needed
incident_number = response.json()["incident"]["display_id"]
print(f"Incident created successfully! Incident Number: {incident_number}")
else:
print(f"Error creating incident: {response.text}")
title = "TEST"
description = "TEST"
priority = "Low"
catalog_item_id = “123456
Employee_Email = “abc@abc@gmail.com
category = “ABC”
subcategory = “ABC”
# Call the function to create the incident
create_incident(title, description, priority, catalog_item_id, category, subcategory)