Service Desk Practitioners Forum

Error messages using service desk web api (4.5 & 5.1)

David Heinecke
New Member.

Error messages using service desk web api (4.5 & 5.1)

I am working on an integration product that needs to be able to create workflows in SD 4.5 and 5.1. My product is written in java and I am using the SD web api to perform the integration. The problem I am having is that my application needs to selectively handle error conditions from SD, and SD seems only to throw runtime exceptions.

As an example: my application tries to look up a problem by it's id. If the problem can't be found (because it doesn't exist any longer in SD) then I get a RuntimeException. If the user credentials are wrong, then I get the same RuntimeException. However, I need to take a different corrective action if the workflow has been deleted vs. whether the credentials are incorrect.

Up until now I have just tried to match on the message from the RuntimeException (e.g. "No item found with this ID. Please enter an existing ID.") to make the determination as to why the remote call failed. This seems extremely flimsy to me and doesn't even appear to work between SD versions 4.5 and 5.1.

Is there a better way to get an error code or a result code using the web api that definitively decodes why the call failed that I can use programmatically?

Thanks in advance!