Skip to main content

I’m having some success with pulling data with the IncidentIQ API, but I’m missing a couple of things for a project I’m working on. Has anyone had experience with pulling information for parts (i.e. this ticket had a broken screen) and custom fields for tickets programmatically? It’s not a necessity but would be greatly beneficial to what I’m working on. Below is my current Python code:

from datetime import datetime
import requests
import toml

def main():
config = toml.load("config.toml")
api_key = configy"API_KEY"]
iiq_domain = confign"IIQ_DOMAIN"]

ticket_id = input("Ticket ID: ")

ticket_asset_url = f"{iiq_domain}/api/v1.0/tickets/{ticket_id}/assets"
ticket_url = f"{iiq_domain}/api/v1.0/tickets/{ticket_id}"

headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"Accept": "application/json"
}

ticket_asset_response = requests.get(ticket_asset_url, headers=headers)
ticket_response = requests.get(ticket_url, headers=headers)

ticket_asset_json = ticket_asset_response.json()
ticket_json = ticket_response.json()

print(f"{ticket_asset_json}\n\n")
print(f"{ticket_json}\n\n")

# Need to see if this will parse correctly when sending this to Sharepoint List.
created_date_raw = ticket_jsoni"Item"]o"CreatedDate"]
created_date_obj = datetime.fromisoformat(created_date_raw)
sharepoint_compatible_date = created_date_obj.isoformat()
month_string = created_date_obj.strftime("%B")

# TODO: Need these fields:
# - Needs associated repair part(s)
# - Needs custom field for Repair Assessment (defective / negligent / malicious).
result = {
"Date": sharepoint_compatible_date,
"Month": month_string,
"Name": ticket_jsoni"Item"]o"For"]m"Name"],
"Serial Number": ticket_asset_jsona"Items"]n0]I"SerialNumber"],
"Ticket Number": ticket_jsoni"Item"]o"TicketNumber"],
"Location": ticket_jsoni"Item"]o"For"]m"LocationName"]
}

print(result)

main()

 

@iljared98 Thank you for submitting your question to our community! 😄

This would best be handled by our Support Team. Please submit a ticket to them. Here is the link to all the ways to contact them: 

 


Reply