Error Handling

HTTP Response Body

By default the MOO API uses HTTP status codes to indicate the state of a request. 200 indicates the request has succeeded (but might have warnings). Any other response code indicates that the response did not succeed. If the status code is anything other than 200, then the standard response structure will be replaced with an Exception structure:

This default status code can be overriden using the optional errorsAsOK parameter to any API method. If errorsAsOK is set to true for a request then a 200 OK response will be returned for an exception.

Response codes

The response statuses we will return are listed below:

200 OK - This means that the request was processed successfully. Note that this DOESN'T mean that everything is fine with your Pack data. However, it does mean however we have accepted the Pack in whatever state you sent it. Do look at any warnings

401 Unauthorized - An authorization failure will stop the request immediately. This can happen for a number of reasons:

If you haven't correctly received an authToken by going through the OAuth authorization process (for 3-legged requests)

If you haven't correctly signed the OAuth request (either 2-legged or 3-legged requests)

If you haven't correctly used any other supported authentication mechanism.

Not all API methods are available to all API clients. By default, you will only have the ability to make a moo.pack.createPack and moo.image.uploadImage method calls. See the Methods page for more details of the permissions required. Please contact MOO if you require more permissions for your application.

400 Bad Request - This will happen if the request you authenticated successfully, but the request data you passed was in some way invalid. Reasons are:

Malformed JSON. Note that we strongly validate the JSON structure. In particular, trailing commas at the end of arrays will cause failures - the structure must be "perfect".

Malformed request objects. If the Pack object you supply is valid JSON, but not valid as a Pack object (e.g. you've given us a "sidess" array), then you will receive a message about why we couldn't unmarshall the request.

Validation. If there was a severe validation failure that means the request cannot be processed. At the moment, this will only apply if you try to use a productCode inside the Pack object that doesn't exist. In this case, we cannot let the request proceed as the results will be completely undefined, so we reject the request completely.

500 Internal Server Error - This stops the request immediately as something "bad" happened. We should have listed all the possible failure causes below. If you find some other reason, or the exception message is "An unrecoverable error occurred" please contact MOO as this will be a bug (it's either a logic error, or an oversight on our part on the exception messaging):

You have tried to call a method that does not exist - check you haven't typo'ed the method parameter value.

You have tried to call a method with the wrong HTTP method type (i.e. GET or POST).

The Pack you were trying to act of (moo.pack.getPack or moo.pack.updatePack) doesn't exist

The product code for which you are trying to create a Pack doesn't exist (moo.pack.createPack)

The image you tried to upload or import was not able to be successfully processed (moo.pack.importImage or moo.pack.uploadImage)

You are trying to add a Pack to the cart which has validation failures. There must be 0 validation warnings in order to add a pack to the cart (moo.pack.addToCart)

Something else unexpected went wrong. This is the case where the exception message will be "An unrecoverable error occurred". If you find this, please contact MOO so we can resolve the issue one way or another.