Error Handling

The API calls return error data that your client application can use to identify and resolve runtime errors. If an error occurs during the invocation of most API calls, then the API provides the following types of error handling:

For errors resulting from badly formed messages, failed authentication, or similar problems, the API returns a fault message with an associated Exception Code.

For most calls, if the error occurs because of a problem specific to the query, the API returns an Error.

Exception Handling

What happens if a WebAPI controller throws an uncaught exception? By default, most exceptions are translated into an HTTP response with status code 500, Internal Server Error. The HttpResponseException type is a special case. This exception returns any HTTP status code that you specify in the exception constructor. For example, the following method returns 404, Not Found, if the id parameter is not valid.

Sample:

public Product GetProduct(int id) {
Product item = repository.Get(id);
if (item == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return item;
}

In case of failure, the controller methods throw an HttpResponseException exception with the appropriate error message, which allows for a given HttpResponseMessage to be returned to the client.

API Fault Element

Fault Description
NO_WO_NUMBER_OR_ID The requested action requires a WO number or id.
INVALID_QUOTE_ID The requested action requires a valid quote id.
INVALID_INVOICE_ID The requested action requires a valid invoice id.
EXISTING_INVOICE The WO already has an active invoice.
INVALID_QUOTE_ORDER_ID The requested action requires a quote order number 1 or 2.
WO_NOT_FOUND The WO requested could not be found with the specified parameters.
NO_COMMENT_SUPPLIED No comment was included to the request. A comment is required for this operation.
NO_WO_SUPPLIED No WO was included to the request. A WO is required for this operation.
INVALID_DNE_UPDATE DNE value cannot be changed.
INVALID_ACTUAL_DATE_UPDATE An actual date value cannot be changed.
INVALID_MODIFIED_DATE_RANGE Filtering by Modified DateTime requires Equals comparission or setting a Range of Dates.
INVALID_STATUS_CODE StatusCode value is not valid.
INVOICE_NOT_FOUND The invoice could not be found.
TRIPCHARGE_RATE_NOT_FOUND The trip charge rate could not be found.
INVALID_ATTACHMENT_EXTENSION_TYPE The attachment extension type {0} is not valid. Valid extension type is: {1}
QUOTE_NOT_FOUND No quotes could be found for the supplied WO.
NO_QUOTE_SUPPLIED No quote was included to the request. A quote is required for this operation.
NO_INVOICE_SUPPLIED No invoice was included to the request. An invoice is required for this operation.
INVALID_PVINV_STATUS The action requires PVINV WO status.
INVALID_PQTE_STATUS The action requires PQTE WO status.
NO_FILTER_CRITERIA The requested action requires a filter criteria.
NO_VENDOR_CODE Please provide the calling client as part of the Header information.