layout | group | subgroup | title | menu_title | menu_order | version | github_link | redirect_from |
---|---|---|---|---|---|---|---|---|
default |
get-started |
C_REST |
Review the response |
Review the response |
3 |
2.0 |
get-started/gs-web-api-response.md |
/guides/v1.0/get-started/gs-web-api-response.html |
Each web API call returns an HTTP status code that reflects the result of a request.
POST
, PUT
, and GET
web API calls return a response payload.
Each web API call returns an HTTP status code that reflects the result of a request:
HTTP code | Meaning | Description |
---|---|---|
200 | Success | The framework returns HTTP 200 to the caller upon success. |
400 | Bad Request | If service implementation throws either Magento_Service_Exception or its derivative, framework returns a HTTP 400 with a error response including the service-specific error code and message. |
401 | Unauthorized | If an error occurs during credential validation or if service throws Magento_Service_AuthorizationException , framework returns HTTP 401. |
404 | Incorrect URI/Resource not found | If the request endpoint is not correct, framework returns HTTP 404. If service throws Magento_Service_ResourceNotFoundException , framework returns HTTP 404. |
500 | System Errors | If service implementation throws any other exception like network errors, database communication, framework returns HTTP 500. |
POST
, PUT
, and GET
web API calls return a response payload. This payload is a JSON- or XML-formatted response body. The Accept: application/<FORMAT>
header in the request determines the format of the response body, where <FORMAT>
is either json
or xml
.
The response payload depends on the call.
For example, a GET /V1/customers/:customerId
call returns the following payload:
{% highlight json %} { "customers": { "customer": { "email": "user@example.com", "firstname": "John", "lastname": "Doe" }, "addresses": [ { "defaultShipping": true, "defaultBilling": true, "firstname": "John", "lastname": "Doe", "region": { "regionCode": "CA", "region": "California", "regionId": 12 }, "postcode": "90001", "street": ["Zoe Ave"], "city": "Los Angeles", "telephone": "555-000-00-00", "countryId": "US" } ] } } {% endhighlight %}
This JSON-formatted response body includes a customer
object with the customer email, first name, and last name, and customer address information. The information in this response body shows account information for the specified customer.