Handling Errors
The API returns error data when a request fails. Your client application needs to identify and handle these errors.
The XML API uses the status
attribute for the response element and each command response element to indicate success or failure.
-
The
response
element includes astatus
attribute with the value1
if the XML request is badly formed or could not be parsed. It has no attributes otherwise.<response status="1">unclosed token at line 1, column 322</response>
-
If the request was well formed, each command response element includes a
status
attribute. Thestatus
attribute value is0
if the operation succeeded or a different value (error code) if the operation failed.In some cases of failed operation, the command response element may include additional error information using the
errors
child element <errors>.<response> <Add status="1106"> <errors>Some error description</errors> </Add> </response>
The SOAP API uses two types of errors:
-
SOAP Faults — The SOAP API uses the standard SOAP Fault element in case of incorrect usage, badly formed SOAP messages, failed authentication, or similar problems. The SOAP Fault includes a
faultcode
element with the error code, afaultstring
element with a brief description of the error, and adetail
element with the error code.The following example shows the Fault element returned when sending an expired or invalid OAuth 2.0 access token [
access_token
] or Session ID [sessionId
] in a session header [SessionHeader
] with your request.<SOAP-ENV:Fault> <faultcode>SOAP-ENV:9</faultcode> <faultstring>Logged out</faultstring> <faultactor>http://www.soaplite.com/custom</faultactor> <detail> <Error xsi:type="namesp7:Error"> <code xsi:type="xsd:int">9</code> </Error> </detail> </SOAP-ENV:Fault>
-
SOAP Command Errors — The response objects for each command have an
errors
property. If errors occur because of a problem specific to the operation, theerrors
property is an array of one or moreoaError
objects (seeError
). TheoaError
object contains the errorcode
and may also contain the error description [text
].
To obtain more information about the error returned, you can use the Read
(XML) or read()
(SOAP) command to retrieve the Error
object which includes a short description and additional information about the error.
A list of error codes and their descriptions is also included in this guide for reference. See Error Codes.