You are here

What does a response look like?

All responses are JSON objects. The format of the response object depends on the request. The object can contain an entry object, an entry and a relations object, a list object, or an error object. Note that if a property or an entire object has no value, then it is not returned in the parent object.

Entry object

An API call which returns information about a single entity will return in an entry object. This is an example response from a request for information on a site with a specific site-id:

{
   "entry":{
      "title":"Fred Blogg's Home",
      "description":"Fred Blogg's private home site.",
      "visibility":"PRIVATE",
      "id":"fred-bloggs-yourcompany-com"
   }
}
Note that the entry object's properties are variable and depend on the API call made.

Relations object

If an API method specifies the relations parameter, then any included children will be returned in a relations object. This is an example of a relations object:
      
      "relations" : {
        "containers" : {
          "list" : {
            "pagination" : {
              "count" : 1,
              "hasMoreItems" : false,
              "totalItems" : 1,
              "skipCount" : 0,
              "maxItems" : 100
            },
            "entries" : [ {
              "entry" : {
                "id" : "b9f8c112-66b9-4733-a77d-46e61c395706",
                "folderId" : "documentLibrary"
              }
            } ]
          }
        }
      }

List object

An API call which returns information about a several entities will return in a list object. A list will always have two properties, pagination and entries. The pagination object is described in Pagination. The entries object is an array of entry objects. Here is an example response from a request for information on all sites:

{
   "list":{
      "pagination":{
         "count":1,
         "hasMoreItems":false,
         "totalItems":1,
         "skipCount":0,
         "maxItems":10
      },
      "entries":[
         {
            "entry":{
               "title":"Fred Blogg's Home",
               "description":"Fred Blogg's private home site.",
               "visibility":"PRIVATE",
               "id":"fred-bloggs-yourcompany-com"
            }
         }
      ]
   }
}

Error object

An API call which fails for some reason will return an error object containing these properties:

errorKey
A unique string identifier.
statusCode
The HTTP status code for the type of error. The same code is returned in the HTTP response.
briefSummary
Description of the cause of the error.
descriptionUrl
A URL to the REST API Explorer.
stackTrace

For security reasons, the stack trace is not displayed.

If there is a problem you will no longer see a stack trace in the client. If it's an un-handled error, that is, a 500 HTTP status code a unique logId property will be returned. This can be correlated to an error in the log file.

If it's a handled error, that is, 403 Forbidden, there won't be a stack trace emitted in the log or a logId provided. To force the stack trace to be shown in the log file debug mode needs to be enabled for the ApiWebScript class. The following needs to be added to log4j.properties:

log4j.logger.org.alfresco.rest.framework.webscripts.ApiWebScript=DEBUG
additionalState
This optional property if it is present contains a free-form JSON object with additional information on the state of the server and/or the request.
This is an example of an error object from a request for a specific site-id that does not exist on the server:
{
  "error": {
    "errorKey": "framework.exception.EntityNotFound",
    "statusCode": 404,
    "briefSummary": "01160005 The entity with id: 55eeb019-7d35-478c-bae7-8863fa234761 was not found",
    "stackTrace": "For security reasons the stack trace is no longer displayed, but the property is kept for previous versions",
    "descriptionURL": "https://api-explorer.alfresco.com"
  }
}