Data Handling

The data sections of the card can be defined on different levels (card level, header level, filter-definition level or content level). Inner level data sections will take precedence. Defining a data section configures how the card will handle its data. A data section will result in a JSON model creation which can be used in binding syntaxes later on. There are a few possible configurations for a data section:

  1. Using static data by providing the "json" property.
  2. Requesting data by providing the "request" property.
  3. Use the Extension to get data by providing the "extension" property.
  4. Provide "path" only to specify the context path of the current level.

Data Properties

Property Type Required Description Schema Version Since
request Request No An object defining a request. 1.14.0 1.65
json Object No A data object. 1.14.0 1.65
extension Extension No An object defining which method of an Extension to be called for fetching the data. 1.79
name string No Name for the data section.
If this name is given, a model with the same name is assigned to the card and can be used inside the manifest and inside an extension or a Component card.
A unique name must be used for each individual data section. The names "parameters", "filters", "context" and "i18n" are reserved for cards and must not be used.
See this sample.
Note: This property is experimental.
1.30 1.86
path string No The context path. Default value is "/". 1.14.0 1.65
updateInterval number No The interval in seconds on which the data will be updated. 1.15.0 1.65
mockData MockData No Mock data configuration. It is used when the card preview mode is set to "MockData" by the hosting environment. For more information see Card's previewMode property.
Note: This property is experimental.
1.52.0 1.112
Request Properties
Property Type Required Description Schema Version Since
mode string No The mode of the request. Possible values are "cors", "no-cors", "same-origin". Default value is "cors". 1.14.0 1.65
url string Yes The URL of the request. Relative paths like "data.json", "./data.json" and "../data.json" are going to be resolved relatively to the manifest base path. 1.14.0 1.65
method string No The HTTP method. Possible values are "GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", and "HEAD". Default value is "GET". 1.14.0 1.65
parameters Object No The request parameters to be sent to the server. If the HTTP method is "POST", "PUT", "PATCH", or "DELETE" the parameters will be put as key/value pairs into the body of the request. If the method doesn't have an entity body, such as the "GET" or "HEAD" methods, the data is appended to the URL.

Default encoding is application/x-www-form-urlencoded. Also JSON is supported for the body encoding (see sample with GraphQL). If you need it add a header Content-Type: application/json"
1.14.0 1.65
headers Object No The HTTP headers of the request. 1.14.0 1.65
retryAfter integer No Number of seconds before the request is retried if it failed the previous time.
Request will be retried only if it failed with status code 429 or 503.
If the server response contains "Retry-After" header - it will be used instead of this property.
Only number of seconds is supported for both this property and the "Retry-After" header. Other values will be ignored.
1.34.0 1.92
timeout integer No A timeout (in milliseconds) for the request. A value of 0 means there will be no timeout. Note This property is deprecated. The default browser timeout which is normally more than 90s will be used. 1.51.0 1.111
withCredentials boolean No Indicates whether cross-site requests should be made using credentials. 1.17.0 1.71
batch Object<string,Batch> No A map of requests, which should be batched together.
If used the main request will be sent with content type multipart/mixed and its body will contain all requests specified in the map.
Can be used for OData V2 and V4 batch requests.
In the binding the result from each request can be accessed by the key of the corresponding request (see sample with OData batch request).
Note: This property is experimental.
1.33.0 1.90
cache Cache No An object defining the cache behaviour for the requested data.
Note: This property is experimental.
1.35.0 1.94
Batch Properties (Experimental)
Property Type Required Description Schema Version Since
url string Yes Absolute or relative URL. If the URL contains Content-ID reference then the reference has to be specified as zero-based index of the referred request inside the change set. 1.33.0 1.90
method string Yes The HTTP method. Only "GET", "POST", "PUT", "PATCH", and "DELETE" are allowed. Use capital letters only. 1.33.0 1.90
headers Object No Map of request headers. RFC-2047 encoding rules are not supported. Nevertheless, non US-ASCII values can be used. 1.33.0 1.90
body Object No Request body. If specified, oRequest.headers map must contain "Content-Type" header either without "charset" parameter or with "charset" parameter having value "UTF-8". 1.33.0 1.90
Cache Properties (Experimental)

Note: This feature is dependent on the host environment and if it’s not prepared, the card data requests will work without caching. If you are developing a host environment - see the instructions in the Integrate section.

Caching reflects how data requests are performed. In the card’s configuration it is enabled by default and would work, given that there is caching enablement in the host environment.

With the “cache” property you can specify how your card will behave about caching. You can control how long does the cached data is considered fresh and therefore shown to the user. You can also set whether a stale cache (one which is not fresh) can be shown to the user while fresh data is fetched.

For example, if maxAge is 3600 and staleWhileRevalidate is true, each time when the users open the page in up to one hour, they will see the cached data from their first visit. When the page is opened again after one hour, the user will briefly see the old, cached data, while the fresh data is being fetched. Then the fresh data will be shown and saved in the cache to be used in next one hour.

The default behavior for the card is maxAge: 0 and staleWhileRevalidate: true.

See the samples in the Explore section.

Property Type Required Default Value Description Schema Version Since
enabled boolean No true If set to false the cache is disabled and it will not be stored in the browser's cache. 1.35.0 1.94
maxAge integer No 0 The maximum number of seconds for which the cached data is considered fresh and can be shown to the user. 1.35.0 1.94
staleWhileRevalidate boolean No true A stale cache can be shown to the user until the fresh data is fetched. 1.35.0 1.94
Extension Properties
Property Type Required Description Schema Version Since
method string Yes The name of the Extension method, which returns a promise and resolves with JSON. 1.79
args array No The arguments with which the method will be called. 1.79
MockData Properties (Experimental)
Property Type Required Description Schema Version Since
request Request No An object defining a request. 1.52.0 1.112
json Object No A data object. 1.52.0 1.112
extension Extension No An object defining which method of an Extension to be called for fetching the data. 1.52.0 1.112

Examples

Card level data section with static JSON where the header and content sets their own context path:

{
	"sap.card": {
		"type": "List",
		"data": {
			"json": {
				"info": {
					"header": "Some title"
				},
				"items": [
					{
						"name": "Item 1",
						"description": "Item 1 description"
					},
					{
						"name": "Item 2",
						"description": "Item 2 description"
					},
					{
						"name": "Item 3",
						"description": "Item 3 description"
					}
				]
			}
		},
		"header": {
			"data": {
				"path": "/info"
			},
			"title": "{header}"
		},
		"content": {
			"data": {
				"path": "/items"
			},
			"item": {
				"title": "{name}",
				"description": "{description}"
			}
		}
	}
}

Content level data section with request and update interval:

The structure of the /api/items API response:

{
	"items": [
		{
			"name": "Item 1",
			"description": "Item 1 description"
		},
		{
			"name": "Item 2",
			"description": "Item 2 description"
		},
		{
			"name": "Item 3",
			"description": "Item 3 description"
		}
	]
}

The manifest:

{
	"sap.card": {
		"type": "List",
		"header": {
			"title": "Some title"
		},
		"content": {
			"data": {
				"request": {
					"url": "../api/items"
				},
				"updateInterval": 300,
				"path": "/items"
			},
			"item": {
				"title": "{name}",
				"description": "{description}"
			}
		}
	}
}
Try it Out