APIResult

All ChannelAdvisor API services use a common "base" return type for its operations, called APIResult. An API result is a complex type, and is defined as follows:

APIResult Type Fields

Field Name

Field Type

Description

Status

ResultStatus

Whether the operation succeeded or failed. SOAP Faults may also be thrown by an operation.
This is an enumerated string value containing one of the following:

  • Success
  • Failure

MessageCode

int

Optional: Operation specific message code, generally used in case of failure.

Message

string

Optional: Operation specific message, generally used in failure reporting.

Data

string

Optional: Operation specific data which caused the failure.

ResultData

Templatized Type

The results value returned from the operation.

APIResult is templatized to allow any type to be used as the ResultData member, so there will be a variation of APIResult for each specific template type used in a service.

For example, an operation that returns a string will return an APIResultOfString, where ResultData is strongly typed as string. Both simple and complex types are used in the ChannelAdvisor API as ResultData.


Example Response from SubmitOrder
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<SubmitOrderResponse xmlns="http://api.channeladvisor.com/webservices/">
<SubmitOrderResult>
<Status>Success</Status>
<MessageCode>0</MessageCode>
<ResultData>9179400</ResultData>
</SubmitOrderResult>
</SubmitOrderResponse>
</soap:Body>
</soap:Envelope>

Error Handling

Expectations for APIResult is a simply structure which can be used to give appropriate feedback to whatever is calling the method.  Error handling is most important when developing good results.  When development on a method is initialized, testing field constraints and enumeration limitations are important. Barrier testing
In the case where an Error message is not handled, it is likely you will receive this message:


<Message>An unrecognized error code 118 has been encountered.  No other information is available.</Message>

When the Error is handled, you can test the response with an assertion to not contain the above response.  As error handling gets completed, proper messages from the API Call are displayed in the response.  Note below that MessageCode matches the Message returned.  The same MessageCode can be the result value for many different API Calls and the response message is handed back.


Example response from SubmitOrder where a FRIENDLY Error message is handed back with a proper Error message&nbsp;
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<SubmitOrderResponse xmlns="http://api.channeladvisor.com/webservices/">
<SubmitOrderResult>
<Status>Failure</Status>
<MessageCode>118</MessageCode>
<Message>The Address should be less than 75 characters.</Message>
<ResultData>0</ResultData>
</SubmitOrderResult>
</SubmitOrderResponse>
</soap:Body>
</soap:Envelope>