Learn about the basics of Graniitti API responses:
The Graniitti API returns the following headers in a response.
Table: Graniitti API response headers
|Headers allowed in a request.|
HTTP methods allowed for sending a request. The allowed methods vary based on resource and resource type.
For more information about which methods the different resource types support, see the Graniitti API reference.
|Domains from which requests are accepted in cross-origin resource sharing (CORS).|
|Caching behavior that client applications and other caching mechanisms along the request/response chain must follow.|
|Content encoding (compression) applied to the response body.|
|Media type of the response body.|
|Date and time at which the response was sent.|
|Information about the server software that handled the request and sent the response.|
|HTTP Strict Transport Security (HSTS) policy specifying for how long (in seconds) the client application should access the server only through secure HTTPS connections.|
|Prevents browsers from MIME-sniffing the response body away from the media type declared in the |
|Specifies whether the client application is allowed to render the response body in a frame (a |
|Specifies whether and what type of cross-site scripting (XSS) protection is enabled for the browser.|
For more information about the standard HTTP headers, see the header fields registry maintained by IANA.
All responses use the JSON format for the body.
A single resource is returned as an object. The following example shows a user object.
A collection of resources is returned as an array of objects. The following example shows an array of user objects.
If a GET request targets an endpoint that potentially contains multiple resources, the response body is always an array of objects, even in cases where the API only returns a single resource (either because the endpoint only contains a single resource or because filtering resulted in a single resource).
For POST, PUT, and PATCH requests, the response body contains the data for the new or updated resource.
The response body for paginated results looks slightly different. For more information, see Paginating.
If a request fails, the response body contains information about the error that occurred, represented as a JSON object.
The following example shows the response to a POST request that tried to create a user that already existed (identified by email address).
Table: Graniitti API error message fields
|Error message field||Description|
|Error code. This is always "0".|
|Short error message that provides a summary of the error.|
|Detailed information about the error, if available.|
Response status codes
The API uses standard HTTP status codes to indicate the success or failure of a request. A
2xx status code indicates success, while a
4xx status code indicates failure of some kind.
Table: Graniitti API response status codes
|The server successfully processed the request. The response includes the associated resource data.|
|The server successfully deleted the target resource. The response does not include any resource data.|
|The server could not process the request due to an error in the request.||Check that the request uses the correct URL, includes the necessary headers, and, in case of a POST or PUT request, contains a valid JSON body.|
|The server could not authenticate the request because the access token is invalid or missing.||Check that the request includes a valid access token.|
|The server successfully authenticated the request, but could not authorize access to the target resource because the access token does not grant sufficient permission.||Check that you're targeting a resource or resources that you have access to.|
|The server could not find the requested resource.||Check that you're using the correct resource IDs.|
The server could not process the request because the target resource failed to fulfill one or more preconditions.
This status code only applies to DELETE requests to
|If you want to delete the content template, first remove it from all modifications.|