I'm using the endpoint /api/v1.0/tickets/slas to retrieve SLA information related to tickets; however, it returns a 500 Internal Server Error when the itemcount is 0.
@HLicea 51023bd misd Thank you for submitting your question to our community!
I have reached out to our Support Team API masters, but in the meantime, @jclark @MattHenry @bclark @curtis.bohlmeyer any ideas to share?
That endpoint is right.
Since different products can have different SLA’s, you likely need to add the “ProductId” header to specify Facilities or Ticketing. Your product ID’s should be listed in Admin > Developer Tools in iiQ.
I'm curious about why everything works smoothly when the ItemCount is greater than 0 without any changes. Also, is it normal that the endpoint returns statuscode:500 when there’s no data?
In my experience, IIQ returns 500s when there’s something malformed or missing about the request. As @jclark mentioned, there’s probably a missing payload param.
I have a specific block of code for detecting 500s on POST because sometimes they payload isn’t formatted correctly. Python snippet below.
except requests.exceptions.HTTPError as e: logging.warning( f"HTTPError exception for API {method} call to {url} with " f"payload {iiq_payload} | Message: {e}" # | Response: {response} ) if e.response.status_code == 502 and timeout < max_timeout: sleep(timeout) call_api( url=url, method=method, iiq_payload=iiq_payload, iiq_headers=iiq_headers, params=params, timeout=timeout, max_timeout=max_timeout, ) elif ( e.response.status_code == 500 and method.upper() == "POST" ): # Try to fix payload by converting it to str iiq_payload = json.dumps(iiq_payload) call_api( url=url, method=method, iiq_payload=iiq_payload, iiq_headers=iiq_headers, params=params, timeout=timeout, max_timeout=max_timeout, ) else: raise
Thank you @LCampbell for that additional information!
Thank you for your response! I have implemented the code you suggested to verify the payloads, and it seems to be structured correctly. I also added the ProductID to the header, but I am still running into the same issue. The only scenario in which I have detected this problem is when there is no data to retrieve. Is there any documentation available for this endpoint that I could reference? It would help me ensure that my headers and payloads are set up correctly, as well as confirm that I am using the correct endpoint for my target. Thank you very much!
@HLicea 51023bd misd Our documentation for APIs are still being worked on and developed by our dev team. However, there is a developer section within you platform for specific dev tools.
@Kathryn Carter » I think this is a bug for this endpoint and should be escalated to the engineering team. More info below.
@HLicea 51023bd misd » I think your payload is correct, and I can confirm that it only 500s when the resulting response has zero items. I verified through the website that I didn’t have any tickets created on 11/27/2024.
The way I see it, you can either handle the exception when you get a 500 when calling that API, or you can call https://wusd-org.incidentiq.com/api/v1.0/tickets with your filter to get the date range you want, and then run a for loop similar to
for id in ticket_ids: url = f"{base_url}/tickets/{id}/slas" iiq_headers = { "Content-Type": "application/json", "Authorization": bearer_token, } response = requests.get( url, headers=iiq_headers ) # Do something with response
@LCampbell I would suggest submitting a ticket to our Support Team then. Make sure to include this link with your ticket so our team has reference to this thread.
@LCampbell I would suggest submitting a ticket to our Support Team then. Make sure to include this link with your ticket so our team has reference to this thread.
Ticket created!
Thanks so much for your response @LCampbell and @Kathryn Carter. I’ll work on my code to handle this error; I hope we can have a solution from the engineering team. I appreciate your support!