If you make a Magento API call, you are guaranteed to receive some kind of a response. If you make a successful call, you will receive an HTTP response with a 200 OK status.
You can view the response data from any Magento API call in one of the following two formats:
The format of returned data is defined in the request header. The format you choose depends on what you are familiar with most or tools available to you.
The XML response format is a simple XML block.
To set the response format to XML, add the Accept request header with the text/xml value.
A successful call will return the following response (example of retrieving information about stock items):
If an error occurs, the call may return the following response:
To set the response format to JSON, add the Accept request header with the application/json value.
The JSON objects represent a direct mapping of the XML block from the XML response format.
A simple XML error
will be transformed to
A successful API call to the Stock Items resource will return the following XML response:
The JSON equivalent will be as follows:
The list of HTTP status codes that are returned in the API response is described in the Common HTTP Status Codes part of the documentation. There, you can find the list of codes themselves together with their description.